Taking vacation: Pull it together


def hotel_cost(days):
return 140*days

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):
total = days*40
if days >= 7:
total -= 50
elif days >= 3:
total -= 20
return total

def trip_cost(city, total):
return plane_ride_cost(city) + rental_car_cost(total)

There is something wrong with my code but i cant understand what! Its giving me the error that the calculated price is lower than it actually should be.


You forgot to include hotel_cost in trip_cost.

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


But then it shows that 'global name (total) is not defined' and when i add (total) as an argument it shows that only two arguments are allowed!


sorry, forgot to change the parameters
This should fix it:

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


Thanks a lottttttttt!!!!!!!:grin:


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