Python Introducing Lists Using Lists Continental

Daniel Lounsbury
Daniel Lounsbury
1,744 Points

How do I print only the items from a list that start with the letter "A"

as part of this 2 last challenge task 1 is to print all continents, task 2 is to print only continents that begin with the letter "A", I got part 1 correct but part 2 seems to be eluding me.

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

task 1

print("continents:") for continent in continents: print ("* " + continent )

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

print("continents:")
for continent in continents:
    print ("* " + continent ) 

1 Answer

On task 2 you only need one print to pass the challenge. Try this one:

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