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 trialPraise Mupani
1,811 PointsWhy I am getting an AssertionError on this code ?
I am getting an Assertion Error on this code. Can you please help me out?
continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code herecontinent = 0
for x in range(0,2) :
print("* ",continents[x])
3 Answers
Praise Mupani
1,811 PointsThanks this finally did the trick continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]
Your code here
for cont in continents : print("* " + cont)
Steven Parker
231,271 PointsThe instructions ask you to print a list showing each continent, but this code will print only the first 2.
Hint: instead of using "range", this might be a good opportunity to use the list variable itself to control the loop.
Also be aware that code added to a comment line will be ignored (but isn't needed in this case).
Steven Parker
231,271 PointsNote that the "should look similar to" example is just to illustrate the formatting and not intended to be the complete result set.
Praise Mupani
1,811 PointsThanks, Steven may I am getting it all wrong, first, i did the below
for continent in continents : print("*", continent)
and I got the same Assertion error. Then looked on top of the question and I saw the required result as ,
- Asia
- South America that is why I used range to print only two elements of the list
Steven Parker
231,271 PointsThis should have been correct for task 1 (always use Markdown formatting when posting code):
for continent in continents:
print("*", continent)