james mchugh3,925 Points
It says I have 2 errors
I'm trying to list all the continents that start with A. I tried to get them out of the list by their order.
continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ] for continent in continents: print("* " + continent) print(continent[0, 3, 5, 6])
Brendan WhitingFront End Web Development Treehouse Moderator 82,569 Points
In the right-hand panel, it shows the output of the tests. There's one part that gives us an important clue:
line 14, in TypeError: string indices must be integers
This is line 14:
print(continent[0, 3, 5, 6])
When you started your
for loop, you're interating through the
continents list, which is a list of strings, and giving each string the local name
for continent in continents:
continent here is the string, not the list (which is
continents plural). Also, python doesn't let you access a subset of the list or string in the way you're doing it
continent[0, 3, 5, 6].
At any rate, the strategy you're taking here is trying to print out the specific items at specific indices that start with "A". What you really need to do for this challenge is to right code that checks if the first letter is "A" inside the loop. We need your code to work in a way that your part of the code would still work even if there was a different list that had continents starting with "A" in a different order.
Let me know if you have more questions.