Python Introducing Lists Using Lists Continental

Kaden Currier
Kaden Currier
1,325 Points

what did I do wrong

it says invalid syntax at "if items[0] = "A"

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
print("continents:")
for items in continents:
    if items[0] = "A"
    print("* " + items)

1 Answer

Sem Peters
Sem Peters
3,669 Points

The '=' is only used to SET values of variables, like

variable = 129

You should use the '==' operator to check whether something is equal to something.

So something like:

if items[0] == "A"

would be correct.

The '=' is an assignment operator, the '==' is an operator used to compare. Also, your if-statement does not have indentation. It should, just like you did with the for-loop. The following code should be correct:

for items in continents:
    if items[0] == "A"
        print("* " + items)