# Taking a Vacation: 5. Pull it Together. Help Please

#1

This is my code and I can't figure out whats wrong with it

# hotel cost

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

# plane ticket cost

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

# rental car rent

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

# total cost

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

getting this error
Oops, try again. hotel_cost(1) raised an error: maximum recursion depth exceeded

Any help woul be greatly appreciated

#2

I think there could be something wrong with your total cost

So this is what I put down:
def trip_cost(city, days):
return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days)

The only problem is that for your function hotel_cost needs to replace nights with days
I hope this is helpful for you because it worked for me

#3

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

#4

on return put 2 tabs down before return

#5

here is 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
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):
return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days)

#6

The code below is returning an answer in the console (835, none)... but it's also generating the error below, so not allowing me to proceed to the next exercise... Help!

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

def plane_ride_cost(city):
if city == 'Charlotte':
return 183
if city == 'Tampa':
return 220
if city == 'Pittsburgh':
return 222
if city == 'Los Angeles':
return 475
else:
return 'Unknown'

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

print trip_cost(5, "Los Angeles")``````

``````Oops, try again.
trip_cost('Tampa', 9) raised an error: unsupported operand type(s) for -: 'str' and 'int'``````

If anyone has seen this before an has any ideas how to fix it, I'd really appreciate it... I want to get on with the next exercise.

#7

After a lot of mucking about... got a result with the code below:

``````def hotel_cost(days):
return days * 140

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

def plane_ride_cost(city):
if city == "Charlotte":
return 183
if city == "Tampa":
return 220
if city == "Pittsburgh":
return 222
if city == "Los Angeles":
return 475
else:
return "Unknown"
def trip_cost(city,days):
return hotel_cost(days) + rental_car_cost(days) + plane_ride_cost(city)

print trip_cost("Tampa", 5)``````