Python Introducing Lists Using Lists Continental

Whats wrong with my code?

continents = [
    'South America',
    'North America',
# Your code here
for continent in continents:
    print("* " + continent)
    if continent[0] == 'A':
        print("* "+continent)

1 Answer

Ben Aldrich
Ben Aldrich
3,946 Points

Hi if I remember correctly the challenge does not require you to print the results of the continents before checking if they have "A" as the first character. So your code is correct you are just adding in a line not required by the challenge. Your final code should be:

for continent in continents:
    # print(f"* {continent}\n")
    if continent[0] == "A":
        print(f"* {continent}\n")

The challenge is not very clear that you should remove the first part of the challenge from the second. Also if you are wondering what the 'f' is before my strings - I am not using .format and am instead feeding the variable directly into the string - this is called "f-strings" but don't worry about those, they are correct.