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 trialRalph Hellstern
6,106 PointsLists / Python
I am stuck here! Why does the computer not accept my code?
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
for continents in continents[:2]:
print ("*", continents)
2 Answers
Ines Fazlić
Python Web Development Techdegree Student 9,569 PointsHi Ralph, the code you wrote would catch first two continents, and also you should write: for continent in continents, so it diferenciates one item from a list of items you are looping through. And if you only need to print out the continents you dont need indexing. However if this is the second part of the task to print out just the continents that start with A, I will give you a hint..the answer is actually in the question. Remember you can index a string. So if a continent starts with A print it out.
Ines Fazlić
Python Web Development Techdegree Student 9,569 PointsI am glad I was able to help :) Happy coding ;)
Ralph Hellstern
6,106 PointsRalph Hellstern
6,106 PointsThank you! That was helpful...