Python Introducing Lists Using Lists Continental

Michael Kaminski
Michael Kaminski
1,320 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 = [
    'South America',
    'North America',
# Your code here
for continent in continents:
    print("* ", continents[0])
    print("* ", continents[1])

1 Answer

Jeff Muday
Jeff Muday
Treehouse Moderator 24,273 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:

It will have this output

Here are some cities I have visited:
New York
Los Angeles

Good luck with your Python journey!