Python Introducing Lists Using Lists Continental

Sam Cerwinske
PRO
Sam Cerwinske
Pro Student 2,016 Points

print only continents

I'm struggling to figure this out. I can't seem to get this code to work. Halp?

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
print("Continents:")
for continent in continents:
    first_index = (continent[0:1:1]).lower()
    if first_index == "A":
        print(continent)

1 Answer

Stivan Radev
Stivan Radev
6,998 Points
# Here is how to do it
for continent in continents:
    # if the first letter of continent is == 'A', then print it
    if continent[0] == 'A':
        print(f'* {continent}')