Help me this is really wierd and i dont get it


#1

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

HOW DOES THIS CODE NOT WORK???

Oops, try again. Did you create a function called plane_ride_cost?
File “python”, line 11
else city == “Los Angeles”:
^
SyntaxError: invalid syntax

i DONT get it



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


#2

nvrmind i figured it out

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


#4

Since I have a similar problem:

I really don’t understand, why my code here is not working:

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

I always get the error:

File “python”, line 7
elif city == “Tampa”:
^
SyntaxError: invalid syntax

And the message:

Did you create a function called plane_ride_cost?

Maybe I am just a blockhead right now, but I really can’t figure it out.

Thank you very much for your help!

EDIT: Nevermind. I’ve typed it in a second time and now it works.


#6

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