Python Introducing Lists Using Lists Continental

index

how to access continents starting with leeter A

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

1 Answer

Steven Parker
Steven Parker
171,342 Points

You can access individual characters in a string by indexing, using brackets similar to working with a list. Since index numbers start at 0, the first character of "mystring" would be "mystring[0]".

You could then compare that to the letter "A" in a conditional expression.