Python Introducing Lists Using Lists Continental

David Saucedo
David Saucedo
Python Web Development Techdegree Student 936 Points

Challenge question help

Can someone please tell me why this code isn't working for this challenge?

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

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

1 Answer

Louise St. Germain
MOD
Louise St. Germain
Treehouse Moderator 15,555 Points

Hi David,

You're very close! For the second part of the challenge you'll need to update the code you had for the first part of the challenge, instead of creating a second for loop. It's asking to only see only a single list containing the continents that start with "A", but the way your code is above, it lists all the continents (still), and then outputs a second list with the A-continents.

Also, in the output for the A-continents, you don't have the "* " bullet points that it's expecting.

So basically you just need to set the print statement on the last line to include the "* " (exactly like you did it for part 1 of the challenge), and then get rid of your first for loop entirely, so that it only prints out the A-continents.

Once you do that, everything should be working for part 2 of the challenge.

I hope this helps!

Louise St. Germain
Louise St. Germain
Treehouse Moderator 15,555 Points

Haha! Glad to hear I saved you some keyboard shopping. :-D Happy programming!