Python Introducing Lists Using Lists Continental

zoltans
zoltans
1,582 Points

I have stuck with printing out countries beginning with "A". Please, help!

I have no idea how to the second task. I have rewatched Craig's videos, just in case I have missed something. but couldn't find a way to solve this task.

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

5 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 47,493 Points

The assertion error states : '* Asia' not found in 'Asia' . You are missing the bullet.

Efaz Khan
Efaz Khan
5,186 Points

Hi @zoltans , you can use a for loop to iterate through the list and check if the first letter starts with 'A'. First letter of a word can be accessed by cont[0]

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for cont in continents:
    if cont[0] == 'A':
      print(cont)
Efaz Khan
Efaz Khan
5,186 Points

This code should work

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for cont in continents:
    if cont[0] == "A":
        print("* " + cont)
zoltans
zoltans
1,582 Points

Bummer: AssertionError: '* Asia' not found in 'Asia\nAfrica\nAntarctica\nAustralia' : Hmm...not finding the correct items in your output It still isn't giving me the pass. Do you know why?

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for cont in continents:
    if cont[0] == "A":
        print(cont)
zoltans
zoltans
1,582 Points

Thanks a lot you guys!