Taking a vacation getting there


#1

what's wrong with my code. Error says I need to define Plane ride cost and syntax on line 7. Any help appreciated.

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

Hi remove the " " around all your number


#3

tried that still no joy and it's saying (Oops, try again. Did you create a function called plane_ride_cost? ) can't see why. ever question seems so hard. Thanks for your help


#4

Hi can you post your new code ? And read this one how to format your code


#5

Here you go.
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


#6

Try to refresh the page.


#7

will tht help tho umm confused ......... :pensive:


#8

i did but it still dsnt work for me


#9

Hi can you post your code ?
And that topic is from 1 mounth ago.. next time is better if you create a new topic.


#10

oh ok..n sorry for the late reply
def hotel_cost(nights):
hotel_cost= 140
return 140 * nights
def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh"
return 222
if city == "Los Angeles":
return 475


#11

first here

def hotel_cost(nights):
hotel_cost= 140
return 140 * nights

you should remove the hotel_cost= 140

here

elif city == "Pittsburgh"
return 222

its missing the : after "Pittsburgh"
then here

if city == "Los Angeles": 
return 475

It should be elif instead of if


#12

i guess there is something wrong with line 5......n its not working sorry...n i wnt mindif u cnt do it..its ok..i dnt wanna trouble u


#13

but just check if i did it right


#14

your if and elif statement should be indent inside the function like that

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

#15

i will try next time but thnx for the help..coz i needa go
:slight_smile: take care n if it still dsnt work i will ask u


#16

lol now it says theres something wrong with line 10


#17

my teacher helped me with it....n i got it right..thnx for ur help..really appreciate it :slight_smile:


#18

HI sorry it was the last elif statement which had the wrong indent

..........
    elif city == "Pittsburgh":
        return 222
    elif city == "Los Angeles": 
        return 475

#19

oh its fn dnt worry.... n i already did it so it dsnt matter...but thnx anyway :slight_smile:


#22