Python Introducing Lists Using Lists Continental

Craig Ossandon
Craig Ossandon
Python Web Development Techdegree Student 974 Points

Unable to print continents that start with the letter "A"

Hello, I'm just stuck trying to print out the continents that start with the letter "A". I know what I have obviously is not correct, the output just prints out the first three letters of each word. Going over my notes and doing a search, I could not find a workable solution.

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


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

print("Continents that start with A: ")
for word in continents:
    print("* " + word[0:3])

1 Answer

Yodit Nigusse
Yodit Nigusse
4,321 Points
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]


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

print("Continents that start with A: ")
for word in continents:
    # put condition here: 
   # if word[0] == 'A': print("* " + word)
    print("* " + word[0:3]) 
Craig Ossandon
Craig Ossandon
Python Web Development Techdegree Student 974 Points

Hello Yodit, thank you for the help! I was trying an if statement on this before, but I was getting some errors, I forgot the error code. But yes, this worked, I appreciate the help :)