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!
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
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 Parker228,095 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"