Python Introducing Lists Using Lists Continental

Michael Morale
Michael Morale
2,702 Points

Continental TAsk 1

I do not fully understand "for" and iterations just yet. Can some one point me in the right direction? Thanks in advance.

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
print("continents:")
for ["Asia", "South"]  in continents:
        print("Asia", "South America")

2 Answers

Cameron Shannon
Cameron Shannon
19,052 Points

Python’s for statement iterates over the list, in the order that they appear in the list. For example:

# list of continents 
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]

# Means, for each item in the list of continents, 
# print the continent name
for continent in continents:
    print(continent)

# output would be: 
Asia
South America
North America
Africa
Europe
Antarctica
Australia

For task one, you simply need to iterate through the list of continents and add the "*" before the continent when you print it (inside the for loop)

Michael Morale
Michael Morale
2,702 Points

Right. But this one only wants the first two continents. I can't figure that part out.

Michael Morale
Michael Morale
2,702 Points

Never mind, I figured it out. I didn't properly space the asterisk. : D

Cameron Shannon
Cameron Shannon
19,052 Points

Task one isn't asking for only the first two continents. They are just using an example that only shows the first two. Glad you figured it out, I am leaving this comment so others are not confused if they come across your question later on!