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 Introducing Lists Using Lists Continental

Adam Kroner
Adam Kroner
1,460 Points

string indexing

I do not understand what I am missing here, indexing seems to be counted correctly but I keep getting a traceback of string index out of range.

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for continent in continents:
    print("* " + continent[0])
    print("* " + continent[3])
    print("* " + continent[5])
    print("* " + continent[6])

1 Answer

Steven Parker
Steven Parker
229,732 Points

The "continent" variable represents the current name. Not all names have 7 or more characters.

You only need the same print statement you used for task 1. Just add an "if" to control when it happens, and have it test the first character (index 0) to see if it is "A".