Python Introducing Lists Using Lists Continental

Ronald Greer
Ronald Greer
35,843 Points

What's going on with my code?

i am on task 1/1 and i keep getting errors for stuff i have done

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
print("continents:")
for continents in continents:
    print("* " + continents)
Ronald Greer
Ronald Greer
35,843 Points

okay so now it says i have two problems in my code. i changed my code to: print("continents:") for continents in continent: print("* " + continents)

1 Answer

Steven Parker
Steven Parker
176,583 Points

You didn't say what errors you are getting, but at first glance I noticed this:

for continents in continents:

You can't use the same variable name for both the loop variable and the iterable.

Ronald Greer
Ronald Greer
35,843 Points

what should i put as the iterable then?

Steven Parker
Steven Parker
176,583 Points

The iterable is correct, you just need to pick a different name for the loop variable (any name of your choice).

Ronald Greer
Ronald Greer
35,843 Points

ok I'll try that and let you know how it goes

Steven Parker
Steven Parker
176,583 Points

The iterable is the one that comes last, and it was correct before when it referenced the list. It's the loop variable (the first one) that needs a different name.