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 Introducing Lists Using Lists Continental

Michael Kaminski
Michael Kaminski
1,419 Points

I am having trouble printing the proper items in the list, but I think that the code I wrote should work.

I am using a loop, as that is what I am led to believe the question calls for, but I receive a notification that my code is wrong even though it produces the proper result. Can someone provide a really strong hint for this, because I have been trying to solve this and can not.

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for continent in continents:
    print("* ", continents[0])
    print("* ", continents[1])
    break

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

You are pretty close to the proper syntax and block structure-- let's build on that. Since you are really close, I am not going to spoil the victory for you, but hint at the solution.

The loop works such that it iterates over a list. Here's an example where a list is named 'cities'. Each time the block nested under the for loop runs, it will print a new city name.

You don't need a "break" statement in the block. When the loop completes, it will exit.

print("Here are some cities I have visited:")
cities = ['Portland', 'Detroit','New York','Chicago','Los Angeles']
for city in cities:
    print(city)
print("Done!")

It will have this output

Here are some cities I have visited:
Portland
Detroit
New York
Chicago
Los Angeles
Done!

Good luck with your Python journey!