3. Getting There Please Help



Error message that says "Oops try again! Did you create a function called plane_ride_cost()?"
My functions also in red either on my console like in the example. Does that even matter?
*In Dr. Evil voice "What does it all mean bazzle?"

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 can't have a condition since its everything else


Color highlighting is good for singling out keywords, numbers, strings and other expressions, and also for indicating syntax errors. Other than that, it has no meaning, per se. Just easier to read.

The issue in the above code is the last branch. It too should be an elif so it does not default to Los Angeles. When no city is found it will return None which is what the SCT expects.


SWEET BABY JESUS!! Thanks bro why is it something that simple? So lets see if I'm understanding this correctly now if the last else statement has a condition it should be changed to elif so that way it doesnt skip straight to the end and send an error message?


It should be an elif condition so that Los Angeles is only returned if it actually is the city value. An else is not a condition, but a default action in the event none of the cases is met. We don't want or need a default for this function. Python will return None, which is what we do want. The no return default.


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