Ryan Aves2,203 Points
Hi all, Do you know why this version of code won't work for showing the continents beginning with "A"?
I tried creating a new list that only pulls "A" continents, using indexed values from the original continents list. That's still returning errors for some reason.
continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ] # Your code here continents = continents[0,3,5,6] print("Continents:") for continent in continents: print("* " + continent)
Steven Parker182,438 Points
You can't select multiple values from a list that way. But you don't want to modify the list anyway.
Just use an "if" statement so that the "print" only runs when the item begins with "A". The conditional expression can isolate the first letter of a word by using indexing with a value of 0.