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

Python Python Basics (2015) Shopping List App Break

Anthony Ferrero
Anthony Ferrero
2,533 Points

Unsure of 'Loopy' challenge

Unsure of how to pass this challenge, any suggestions?:

I need you to help me finish my loopy function. Inside of the function, I need a forloop that prints each thing in items. But, if the current thing is the string "STOP",break the loop.

''' python def loopy(items): for loopyitem in items: print(loopyitem) if loopyitem == 'STOP': break '''

8 Answers

from what i can understand in your code you are really close to the answer, guy.

its important to realize though that first you have to loop through each item and check if there's a string equal to 'STOP' then break it.

after that you want an else that will finish your loop.. i dont want to give the answer away but I will give you an example

def items():
    for item in items:
        if item == 'STOP'
        break
    else:
_____________________________

hard to read your code since its not formatted look at the markdown cheatsheet to help you out there

but what the task is asking you to do is to make a for loop that goes through each item. first in the loop if that item is equal to the string 'STOP' then break. hint after that you'll need an else loop that does something else

I hope that helps, buddy

Anthony Ferrero
Anthony Ferrero
2,533 Points

Yeah, I have been having difficulty getting my code in the help section, I formatted it appropriately but once I hit submit it doesn't catch it.

make sure theres space from where you start the back ticks and where you state the language

did that hint help you with the challenge?

Anthony Ferrero
Anthony Ferrero
2,533 Points

I added the spaces to the code above and still not showing properly. I have searched left and right and unable to find an answer sadly.

as for formatting your code if you check the Markdown cheatsheet at the bottom of the page it will tell you what to do.

first you want three ticks. the tick shares the tilde key on the top left of ur keyboard (usually) then you want to state the language youre using 'python' (no quotes) insert/enter to drop down a new line and put in your code then you want to return/enter again to drop down a new line again after you have finished writing your code and add another three ticks to wrap it all up

hope this helps you

Anthony Ferrero
Anthony Ferrero
2,533 Points

You're the best! I see what I was doing wrong. Thank you again Darrian!

no problem man glad i could help =]