Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialConner Williams
Courses Plus Student 3,305 PointsWhat does this mean?
I have no idea where to even start on this one.
def loopy(items):
# Code goes here
4 Answers
Ben Reynolds
35,170 PointsThere's a few keywords in the instructions that give away some of the main points: Loop, If, otherwise (else).
A good way to break the ice when you're blanking is to map out the log with comments:
def loopy(items):
# for each item in items
# if something is true:
# do one thing
else:
#do something else
You don't necessarily have to fill them in in order, pick away at the ones you can figure out and work your way down to the more tricky bits
Ben Reynolds
35,170 PointsAn index always starts at 0, and since strings are technically collections, each character has an index:
Here's a sample:
word = "Test"
first_letter = word[0]
Conner Williams
Courses Plus Student 3,305 Pointsokay now how do I skip the line?
Ben Reynolds
35,170 PointsYou could normally do it with the continue keyword, but I saw Steven's comment on the other thread you posted for this one and he's right, this can actually be done without continue or an else block. Here's my revised logic, the change in the "if" statement is the key:
def loopy(items):
# for each item in items
# if first letter is NOT a:
# print something
Conner Williams
Courses Plus Student 3,305 PointsHere is what i have right now. It is giving me a "didnt find the right items printed" message. def loopy(items): # Code goes here for item in items: if item[0] is 'a': print(item)
Conner Williams
Courses Plus Student 3,305 Pointsforgot to include "is not". I completed it. youre saving my life right now.
Ben Reynolds
35,170 PointsAlmost there
- The commented line "code goes here" can go
- There was a comment in my last post that is the last piece: # if first letter is NOT a:
There's a "not equal to" operator that need to replace the word "is" in your if statement
Conner Williams
Courses Plus Student 3,305 PointsConner Williams
Courses Plus Student 3,305 Pointsokay I'm getting closer. How do I tackle the "index" part?