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 trial
Tomer Inbar
2,248 PointsWhy am I getting "Didn't find the right items being printed." ?
For the https://teamtreehouse.com/library/python-basics/shopping-list-app/continue challenge, I am getting the error above.
Task instructions: Loop through every item in items. If the current item's index 0 is the letter "a", continue to the next one. Otherwise, print out every member of items.
My code: def loopy(items): for item in items: if item[0] == "a": continue else: print(items)
Any idea?
1 Answer
Haider Ali
Python Development Techdegree Graduate 24,728 PointsHi, I have taken a look at your code and seen that you have made a simple error. On the last line, you have written print(items) instead of print(item). The code that you have written will print the whole list of items out if the current item's index 0 is not 'a'. However, the challenge asks you just to print out the current item, not the whole list.
This is what your code should look like:
def loopy(items):
for item in items:
if item[0] == "a":
continue
else:
print(item) #here you wrote print(items)
Try and make your loop counter's name slightly different to the name of what you are looping through. It makes it easier to avoid mistakes like this. :)
Tomer Inbar
2,248 PointsTomer Inbar
2,248 PointsHi! Thanks for the review and quick response. Although, I printed "items" and not "item" on purpose as the instructions for this code challenge are:
"... Otherwise, print out every member of items." So, my take on this was that I was asked to print ALL items in the list...