Python TAKING A VACATION Hey, You Never Know! 6/7


#1

I can’t understand what i’m doing wrong. I’m trying to follow the forums but it isn’t really helping. Here’s my code.
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 "None"
def rental_car_cost(days):
cost = 40 * days
if days >= 7:
return cost - 50
elif days in range(3, 7):
return cost - 20
else:
return cost
def money(spending_money):
return spending_money
def trip_cost(city, days,spending_money):
return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + money(spending_money)


#2

You don’t need to define the money function! just add spending_money to your last term.


#3

but now i got this
trip_cost(‘Tampa’, 4, 0) raised an error: global name ‘money’ is not defined

here is the code

if city== “Charlotte” :
return 183
elif city== “Tampa” :
return 220
elif city== “Pittsburgh” :
return 222
elif city== “Los Angeles” :
return 475
else:
return "None"
def rental_car_cost(days):
cost = 40 * days
if days >= 7:
return cost - 50
elif days in range(3, 7):
return cost - 20
else:
return cost
def trip_cost(city, days,spending_money):
return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + money(spending_money)


#4

here is my code, but I get the “trip_cost should take exactly three parameters: city, days, and spending_money (in that order).” error in 7/7 section, while my code is working!
def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city):
if city == “Charlotte” :
return 183
if city == “Tampa” :
return 220
if city == “Pittsburgh” :
return 222
if city == “LosAngeles” :
return 475

def rental_car_cost(days):
if days >= 7:
return (40 * days)-50
elif days >=3:
return (40 * days)-20
else:
return 40 * days

def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money


#5

i see. thank you for the help