Python Introducing Lists Using Lists Continental

Amit Ramjee
Amit Ramjee
702 Points

How to print a list of items with only start with a specific letter?

Hi, I need to print continents that only start with 'A' below. I wrote the code below but for some reason treehouse is not accepting that as the correct answer even though the output print Asia, Africa, Antarctica, and Australia. Is my code written incorrectly?

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

My code here

for continent in continents: if continent.startswith("A"): print (continent)

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

for continent in continents:
    if continent.startswith("A"):
        print (continent)
# Your code here

1 Answer

Cheo R
Cheo R
36,680 Points

You're close. You're missing the extra part '* ' in front of each continent. May also want to remove the space between the word print and the left parenthesis.