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

eestsaid
eestsaid
1,311 Points

problem with Continents Challenge

For the continents challenge which is in the introduction to lists course I'm stuck at calling the list items which start with the letter A. The logic I have used below is to use the for loop to call list items only if they start with the letter A (I am assuming the code is incorrect).

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

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

The error returns

 File "", line 11
    for continents_A in continents:
    ^
IndentationError: unexpected indent

which has really stumped me. Am I on the right path with the original code? Hints (not full solutions would be great). Why is this error showing?

Thanks team.

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

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

1 Answer

Steven Parker
Steven Parker
231,198 Points

That line does not appear to be indented in the code shown above, so I don't understand how it could have an "unexpected indent". But check carefully for tabs or other characters that might not appear here.

But I do see another issue on the next line where there is an index in brackets but the name of the variable being indexed is missing:

    if [0] == "A":              # missing name
    if continents_A[0] == "A":  # fixed
eestsaid
eestsaid
1,311 Points

Thanks Steven - it was the missing name of the variable being indexed.