Python Introducing Lists Using Lists Continental

Rehman Masood
Rehman Masood
3,025 Points

I get an assertion error whenever i run this code

AssertionError: '* Asia' not found in 'Asia\nAfrica\nAntarctica\nAustralia' : Hmm...not finding the correct items in your output

I dont know whether its my code or the challenge

p.s i'm supposed to print out a continent only if it has a letter A in it

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


for continent in continents:
    if continent[0] == 'A':
        print(continent)
Trevor Codner
Trevor Codner
1,174 Points

Hello, I am new to this, but I think you are getting the error because your code only answers part of the question, and I think it is looking for the full solution. have you tried it in the workspace python window?

2 Answers

Khaled Khanfar
Khaled Khanfar
1,135 Points

Hey Rehman,

Sorry I think I was answering a different question when I posted the last answer

the issue with your code is that you should add bullet to the print command ("* " + continent )

Here is the Code try this hope this will help :)

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

for continent in continents:
    if continent[0] == "A":
       print("* " + continent)
Khaled Khanfar
Khaled Khanfar
1,135 Points

Hey Rehman,

I saw the challenge and it's asking you to print a bulleted list to all items not just for the one with "A" letter so you don't have to use if statement

try this code and please get back to me if you have any question

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

don't forget to put a space after the bullet "* " it will still give you an Error because they want the output to look like this

  • Asia
Khaled Khanfar
Khaled Khanfar
1,135 Points

Here is the Code

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


# Your code here
for continent in continents:
    print("* " + continent)