Python Introducing Lists Using Lists Continental

How to iterate through each item to check if only the first word begins with 'A'?

I am unsure how to iterate through each items to check if the first word begins with an 'A'. The challenge implies to use index, however I don't know how that is used to iterate through an entire list. Here is what I have to far...: for continent in continents: if continent #begins with an A:
print( '* ' + continent)

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
    if continent #begins with an A:  
        print( '* ' + continent)

1 Answer

Tariq Saeed
Tariq Saeed
6,654 Points

I am not a Python Student but I got your Answer. what you should also do is to remove the last comma in your array.

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

for continent in continents: if continent.startswith('A'):
print( '* ' + continent)