Getting There (Syntax Error)


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/2?curriculum_id=4f89dab3d788890003000096#


File "python", line 4
if city == "Charlotte"
^
SyntaxError: invalid syntax

Did you create a function called plane_ride_cost?


I expected an output with the inputs I have entered. P.S. I did create a function


 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
    elif city == "Los Angeles"
        return 475


#2

If your syntax isn't valid then your code will not run and your function will not be created. Have a look at the part that your error message is pointing at.

Additionally, there's no point in looking at codecademy's message if there are any error messages from python, if the code crashes for any reason then that's got to be sorted out before anything else about the code can be considered


#3

You forgot to add colons at the end of the if and elif's.
try this:
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
elif city == "Los Angeles":
return 475
:slight_smile:


#4

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