Python Introducing Lists Using Lists Continental

Tapiwa Dzimiri
Tapiwa Dzimiri
1,070 Points

Print Continents that start with letter A

i'm failing to think of the best syntax to search for the letter A in a list and print those with letter A

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
indxcontinents = continents.index("A")
continent = indxcontinents
print("The Lists of Continents: ")
for continent in continents:
    print("* " + continent)

1 Answer

jassim Al-Hatem
jassim Al-Hatem
3,133 Points
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for name in continents:
    if name[0] == "A":
        print(name)

I have been using this way since I started 6 months ago, and I recommend you to use it aswell.