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
Jan Lundeen
6,201 PointsQuestion on loopy function - why did I get the error "Bummer! Didn't find the right items being printed."
I have a question on the challenges in the Shopping List Introduction section in the Python Basic course. On challenge 1 of 2 (I need you to help me finish my loopy function. Inside of the function, I need a for loop that prints each thing in items.
Reminder: Check your syntax and indenting!), I entered the following code:
def loopy(items):
for item in items:
if item == “STOP”:
break
print(item)
Originally, I entered print(item) and got the error "Bummer! Didn't find the right items being printed." When I changed it to print(items), it passed. I think that is because items is the list name.
However, when I answered challenge 2 of 2 (Oops, I forgot that I need to break out of the loop when the current item is the string "STOP". Help me add that code!), I used similiar code and got the error "Bummer! Didn't find the right items being printed." When I changed it to print(item), it passed. It seems to me that it should be print(items), since items is the list name.
def loopy(items):
for item in items:
if item == “STOP”:
break
print(items)
Any idea as to why my code in challenge 2 of 2 is being treated differently?
Thanks,
Jan
2 Answers
Jan Lundeen
6,201 PointsHi Steven,
Thanks for confirming that item is right. I'm a little confused regarding how to find programmer quotes. I can only see one button on my keyboard that has the double quotes. I looked in the Markdown Cheatsheet regarding how to get programmer quotes, but I couldn't find anything. I was also looking on the Markdown Cheatsheet to figure out how Michael Hulet formatted the code, but I'm still a little confused about that too. I want to make it as easy as possible to answer my questions.
Thanks,
Jan
Steven Parker
243,656 Points
The problem is with the quote characters.
I'm not sure why it passed from changing item to items — it shouldn't have. The real problem is that the quotes around the string "STOP" are the wrong type. They are word-processor type quotes (different left and right sides) instead of programmer quotes ("). Now that the code has been properly quoted, the syntax coloring shows the problem by marking the quotes (but not the string) orange.
Once you fix the quotes, you should pass the challenge using the original last line of print(item).
Steven Parker
243,656 PointsSteven Parker
243,656 PointsThanks to Moderator Michael Hulet for formatting the code! Unformatted Python is impossible to analyze.
see Markdown Cheatsheet pop-up below the answer area for instructions how to do it.