Taking a vacation "getting there"



what am I doing wrong? it says: File "python", line 11
else city == "Los Angeles":

                                               SyntaxError: invalid syntax (city something wrong with city?)

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


else doesn't require a condition statement like if and elif. It's just simple else: and always just else:. It's ok to end with elif. It doesn't have to always be if....elif....else..... but can also be if....elif...elif.....

So you can have

elif city == "Los Angeles":

instead of just else.


ohh ok, yeah never thought about that, thank you!


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