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!

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 trial

Python Introducing Lists Using Lists Continental

Lists / 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ć
Ines Fazlić
Python Web Development Techdegree Student 9,569 Points

Hi 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.

Thank you! That was helpful...