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 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 S
Cameron S
20,537 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 S
Cameron S
20,537 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!