ERROR: Oops, try again. plane_ride_cost('Charlotte') returned None instead of the correct value 183


#1

Below is the code that I have wriiten is as below.The error that is popping out as: Oops, try again.
plane_ride_cost('Charlotte') returned None instead of the correct value 183
======================================================
def hotel_cost(nights):
hotel_cost=140*nights
return hotel_cost
def plane_ride_cost (city):
if city=="charlotte":
return 183
elif city=="Tampa":
return 220
elif city=="Pittsburg":
return 222
elif city=="Los Angeles":
return 475

def rental_car_cost(days):
total = 40*days
if days >= 7:
return total-50
elif days >= 3:
return total-20
else:
return total
def trip_cost(city,days):
return hotel_cost(8) + plane_ride_cost("""charlotte""") + rental_car_cost(4)


#2

I have even tried with the function:
def trip_cost(city,days):
return hotel_cost(8) + rental_car_cost(4)
============
And I'm getting the same errors:
Oops, try again.
plane_ride_cost('Charlotte') returned None instead of the correct value 183


#3

Is it because you didn't capitalize Charlotte?


#4

HI this line

return hotel_cost(8) + plane_ride_cost("""charlotte""") + rental_car_cost(4)

where you put 8, """charlotte"""(which should be "charlotte") and 4 you should put days or city so for the hotel_cost() you sould put days...... plane_ride_cost() you should put city and rental_car_cost() you should put days... because days and city are parameter then outside the function trip_cost you could call it


#5

def trip_cost(nights,city,days):
return hotel_cost(nights) + plane_ride_cost(city) + rental_car_cost(days)
===============
ERROR: Oops, try again.
plane_ride_cost('Charlotte') returned None instead of the correct value 183


#6

def trip_cost(nights,city,days):
return hotel_cost(8) + plane_ride_cost("charlotte") + rental_car_cost(4)
===================
Oops, try again.
plane_ride_cost('Charlotte') returned None instead of the correct value 183


#7

I said hotel_cost() to put days .. if you want to know why days and not nights you should read the instruction well


#8

Hi,please check this code,and let me know the error:
def hotel_cost(days):
hotel_cost=140*days
return hotel_cost
def plane_ride_cost (city):
if city=="charlotte":
return 183
elif city=="Tampa":
return 220
elif city=="Pittsburg":
return 222
elif city=="Los Angeles":
return 475

def rental_car_cost(days):
total = 40*days
if days >= 7:
return total-50
elif days >= 3:
return total-20
else:
return total
def trip_cost(city,days):
return hotel_cost(days) + plane_ride_cost("charlotte") + rental_car_cost(days)

===============
ERROR: Oops, try again.
plane_ride_cost('Charlotte') returned None instead of the correct value 183


#9

thi sline

return hotel_cost(days) + plane_ride_cost("charlotte") + rental_car_cost(days)

this part

plane_ride_cost("charlotte")

should be

plane_ride_cost(city)

#10

Thank you for your response.Yes,I have tried this previously,but facing the same error:

def trip_cost(city,days):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)
=============
Oops, try again.
plane_ride_cost('Charlotte') returned None instead of the correct value 183


#11

here

if city=="charlotte":

you chould write "charlotte": with the uppercase C like that "Charlotte": so it should be

if city=="Charlotte":

#12

I'm bit confused in the context of,where are we giving the input to this code?

def hotel_cost(days):
hotel_cost=140*days
return hotel_cost
def plane_ride_cost (city):
if city=="Charlotte":
return 183
elif city=="Tampa":
return 220
elif city=="Pittsburg":
return 222
elif city=="Los Angeles":
return 475

def rental_car_cost(days):
total = 40*days
if days >= 7:
return total-50
elif days >= 3:
return total-20
else:
return total
def trip_cost(city,days):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)
===========================

Oops, try again.
plane_ride_cost('Pittsburgh') returned None instead of the correct value 222

#13

the same for this city

elif city=="Pittsburg":

should be "Pittsburgh" instaed of "Pittsburg" it's missing the h at then end


#14

Good to go!! Thanks much for your help!


#15

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