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 trialWellington Souza
3,121 PointsBreak Challenge Task 1/2
I do not know what is wrong with my code:
loopy(items): for items in items: print(item)
my_items = ["a", "b", "c"] loopy(my_items)
def loopy(items):
for thing in items
print items
my_items = "a"
loopy(my_items)
1 Answer
Gerald Wells
12,763 Pointsfor item in items: #for each item in the list items
print(item) #print each item in the list items
the best way to think of it, at this level is a bag... later you will learn about Data structures and bag interfaces, which at its core contains some similarities but I am off topic. So you have a bag full of different kinds of candy. so
for candy in bag:
print(candy)
it wants to know what each piece in the bag is. The way you have the for loop working is you are calling the bag every iteration instead of the contents.