Python Introducing Lists Using Lists Continental

Nadia Stoyanova-Lyttle
Nadia Stoyanova-Lyttle
Full Stack JavaScript Techdegree Student 2,063 Points

IndentationError

I'm stuck with a task to print continents starting with "A":

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

Your code here

print("continents:") for continent in continents: if continent[0] == "A":
print("* " + continent)

Could you please help?

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

2 Answers

Steven Parker
Steven Parker
171,342 Points

As the system said, there's an indentation issue. Otherwise, you have it just right.

Everything inside a loop must be indented more than the "for" line, and then anything controlled by a conditional must be indented more than the "if":

for continent in continents:
    if continent[0] == 'A':       # indented for loop
        print('* ' + continent)   # indented more for conditional
Nadia Stoyanova-Lyttle
Nadia Stoyanova-Lyttle
Full Stack JavaScript Techdegree Student 2,063 Points

Thank you so much, Steven! It's the little details that I have found the hardest to make right in my early python steps :-)