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 trialAlex Durham
Courses Plus Student 456 Pointsfor loop
can someone help me set up this for loop thanks!
def loopy(items):
for x in range items
2 Answers
Grant Tribble
8,210 PointsHi Alex, It's a little more direct when you're iterating through something specific. Just take out the range and let the for loop go straight to work on that list. It will look like this:
for item in items:
print(item)
This can be shortened even further with a lambda, but that happens a little down the road.
Grant Tribble
8,210 PointsDid you forget to put it in the function def?
Alex Durham
Courses Plus Student 456 Pointsthat was already given i did not have the 'for' indented correctly
Alex Durham
Courses Plus Student 456 PointsAlex Durham
Courses Plus Student 456 Pointsthanks for the help but i typed in exactly what you have and it still says that it is in correct
Alex Durham
Courses Plus Student 456 PointsAlex Durham
Courses Plus Student 456 Pointssorry i got it now thank you for the help!