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 Sequences Sequence Iteration Iterating With For Loops

Write a for loop that iterates over the provided list. The body of the for loop should print the c

where am ii getting wrong

iterating_lists.py
rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
for element in list:
print(element)

3 Answers

Ken Stone
Ken Stone
29,703 Points

Indent print so it's in the for loop and also the for line should be for element in rainbow

rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
for element in rainbow:
  print(element)

The following code helped me pass: rainbow = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']

for item in rainbow: print(item)

thanks guys it worked for me.. i appreciate