Hey, You Never Know!


#1

I'm a little bit stuck with my code. Maybe somebody seeing where is a mistake?
def hotel_cost(night):
return 140 * night

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

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

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


#2

you don't need two functions, just trip_cost.

def trip_cost(city,days,spending_money):

and it would help if your return is in this order,

return spending_money + hotel_cost(days)+ plane_ride_cost(city)+ rental_car_cost(days)


#3

Thanks a lot! I've just deleted function def spending_money() and it's OK!


#4

You're welcome :slight_smile:


#5

thanks alot man...my code was:
return spending_money = the other functions


#6

You're welcome :slight_smile:


#7

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