Welcome to the Treehouse Community
Looking to learn something new?
jamie Macdiarmid2,048 Points
Stuck on this bit. -Do I need to create a 'string' with 'items' in it. -Is there a way to get examples without having to bother people? -How does everyone study i.e lets say for learning 'for loops'. As well as following Kenneths video's does everyone else take written notes or using Treehouse itself for reference i.e when you've forgotten how 'for loops ' work?
def loopy(items): items = "Hammer, nails" for word in 'items': print (word) if word == 'STOP': break
Codin - Codesmite8,600 Points
def loopy(items): for word in items: if word == "STOP": break else: print(word)
You need to remove "" from around items in your for decleration, adding quotation marks around it causes it to become a string.
I do not do much Python programming as I am a PHP developer but normally I would refer to the PHP manual or for instance use google "PHP loop" if I was to forget the syntax.
Here is the python manual/documentation it has a search function to find what you are looking for:
Also there seems to be a pretty good wiki for Python with a search function here (The For Loop page for example): https://wiki.python.org/moin/ForLoop
Steven Parker215,956 Points
Here's a few hints that might help you get a working solution:
- the items will be passed to the function, you don't want to assign your own
- items is a variable, you don't want to put quotes around it
- the challenge wants you to stop before you print the word "STOP"