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 trial

Python

Jay Thomas
Jay Thomas
1,594 Points

Why does a list have to start at [0]?

Take the following code as an example. Why can't I ask the 'If' condition to start at a different point in the list, for example [3], and still get a list of continents that start with A? Why does it have to be [0]?

Why this?

continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]

for continent in continents: if continent[0] == "A":
print("* ", continent)

And not this?

continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]

for continent in continents: if continent[3] == "A":
print("* ", continent)

1 Answer

continent[3] accesses the 4th character of the continent name. For 'South America' this will be the letter t. If that is what you intended to do then it would be fine but the challenge is looking for the 1st character. It sounds like you are confusing this with an index for the continent itself.