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 trialAdam Kroner
1,460 Pointsstring 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 = [
'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
231,269 PointsThe "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".