Python Introducing Lists Using Lists Continental

Aleksandra Laska
Aleksandra Laska
1,955 Points

How to do it ?

??????

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
for continent in continents:
    print("* " + continent)
# Your code here

1 Answer

Josh Keenan
Josh Keenan
17,380 Points

Assuming you mean the second part of the challenge:

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

The if statement accesses the first letter of each string and then checks to see if it is "A" and if so prints it, if that isn't the case the code simply doesn't run and it moves to the next item in the list.