Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKaden Currier
1,490 Pointswhat did I do wrong
it says invalid syntax at "if items[0] = "A"
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
3,669 PointsThe '=' 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)