Welcome to the Treehouse Community
Looking to learn something new?
Can't get this code right in this Treehouse challenge
I have seen all the other questions about this code but none of them work for me. Even when I copy past someones answer it still doesn't work.
Can you tell me whats wrong with this code and why?
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia'] # Your code here for cont in continents: if cont(0) == "A": print("* " + cont)
Your code is quite close, there are just two issues:
- To access the index of a list/string you have to use square brackets  not parenthesis (). So
- Python uses indentation (horizontal spacing) to group code. Code that belongs to the
ifstatements needs to be spaced so that it is considered to be one indentation level deeper than the
If you fix those issues like this:
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia'] # Your code here for cont in continents: if cont == "A": # Parenthesis changed to square brackets print("* " + cont) # Indentation increased
Then your code will work.