Why do I need double = to define my city location?


def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475

Why can't I just use
if city = "Charlotte"

A single equal sign did not work for my function. Why not? I thought the double == is used in mathematics.


A single = is used only in assignments, not comparisons. In Python, == is a comparison operator that checks for identity, both of value and of type.


Thank you so much mtf :smiley:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.