Welcome to the Treehouse Community
Looking to learn something new?
Ali Abadi2,885 Points
Python - String Indexing
Need help, i've used the same code on the python idol and it works without any issues. please help me with this. thanks
continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ] check = 'A' print("continents: ") res = [idx for idx in continents if idx.lower() == check.lower()] print("* " + str(res))
Steven Parker216,133 Points
This runs, but it does something other than what the challenge is asking for. To clarify, here's what the program outputs now:
- ['Asia', 'Africa', 'Antarctica', 'Australia']
But this is what the challenge is looking for:
Also, while list digests are great the error message explicitly says "Make sure you use a for in loop to iterate through the countries".
check = 'A' print("continents: ") for idx in continents: if idx== check: print("* " + idx)