Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRehman Masood
3,025 PointsI 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 = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
if continent[0] == 'A':
print(continent)
2 Answers
Khaled Khanfar
1,135 PointsHey 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
1,135 PointsHey 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
1,135 PointsHere is the Code
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
print("* " + continent)
Trevor Codner
1,700 PointsTrevor Codner
1,700 PointsHello, 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?