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 trialJason Tabaczynski
3,177 PointsAsia not being found in list in Treehouse editor, but I can print the list just fine on my machine running 3.6.5.
Here is my code in both Treehouse and my machine:
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
for continent in continents[0:6]:
print("*" + continent)
When I run the program in cmd prompt, I get the full list from Asia through Australia. However, when I run the code in the editor it tells me Asia isnt being printed and errors out.
I added the [0:6] just to make sure I am getting all of the list items, if I run the program w/o the [0:6] on my machine the whole list is printed out too.
What am I doing wrong?
1 Answer
Steven Parker
231,271 PointsI would expect a slice of [0:6] would cut off the last item, "Australia". Doesn't it do that for you?
But when you get the message "AssertionError: '* Asia' not found...", what it is actually pointing out is not that the name "Asia" is missing, but the space between the asterisk and name is missing.
Add the space, and drop the slice (or extend it to [0:7]) and you should pass task 1.
Jason Tabaczynski
3,177 PointsJason Tabaczynski
3,177 PointsHm, interesting. Didn't think to try that, now it works.
When I run it on my machine with the slice [0:6] it prints out all 7, which is weird. Then if I change it from 6 to 7, it also works. I'll take a look into that.