Python Introducing Lists Using Lists Continental

Holly Bancroft
Holly Bancroft
3,037 Points

How did you solve the question "I'd like you to now only print continents that begin with the letter "A"."?

I am trying to figure out how to only list the continents that begin with "A". Could someone show me how they solved this?

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

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

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,084 Points

There is a hint: Remember that you can access characters in a string by index. For your code you would use continent[0] to access the first character of continent (the index starts at 0).

Then use an if statement and compare this to "A" and if they match print your bulleted list item.