3/7 Please Help! D:


#1

Here is my code, what is wrong?

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

Change the elif to if:
def plane_ride_cost(city):
if city == "Charlotte":
return 183
if city == "Tampa":
return 220
if city == "Pittsburgh":
return 222
if city == "Los Angeles":
return 475
Then it should be correct :smile:


#3

Also make sure to indent


#4

You code is right, May is missing some ident.

This is how you code should to look.

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

#5

Hi, this has helped but was wondering why Los angeles has an elif instead of an else.
E.g
else city == "Los Angeles"

This is wrong but I don't know why.


#6

It's because else does not compare anything so adding something to compare is a syntax error.


#7

Hi, my code is:

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"

However I keep getting the error: "Oops, try again. It looks like plane_ride_cost does not return 183 when the city is Charlotte."

I can't seem to figure out why.I would be grateful if you could help!

Edit: I tried to put the indentations in but can't figure out how, however I have them indented


#8

mine is saying that i did not create a function called plane_ride_cost but i have coded
def plane_ride_cost(city):


#9

I was having this same problem.. when you return numbers, remove the double quotes from them.

so instead of:

def plane_ride_cost(city):
if city == "Charlotte":
return "183"

type it like this instead and it should fix it:

def plane_ride_cost(city):
if city == "Charlotte":
return 183

use proper indenting as well :smile:


#10

hello , below is my code and it works
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
else:
return "Nope"

hotel_cost(2)

:smile:


#11

That helped if you forgot the colons at the end


#12

Yeah I have the same code but for whatever reason when I use mrugerio's code it works fine even though it is the same.


#13

I think you should not put " " for the prices. But I don't know why though? Does anyone know why?


#14

Yes.... This is so simple. You do not want to declare numbers as strings...