# 5. Pull it together error

#1

Alright,so this is my code:

And i get various errors like :!!!trip_cost('Tampa', 4) returned instead of the correct value 920
What causes this?

#2

i see what you did wrong
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):
if days >= 7:
return days*40 - 50
elif days >= 3:
return days*40 - 20
else:
return days*40

that is the proper code

#3

except fix the spacing

#4

put the last 'return' into parentheses like this

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

#5

Cant figure what's the prolem

#6

Check the spacing and allignment @betamaster69950 .. Though you have posted in wrong topic .. Ans is below

``````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 False

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

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

#7

i tried this, and it is not working

#8

this worked for me: By calling days instead of nights at the sum function.

# hotel costs

def hotel_cost(nights):
return 140 * nights

# plane costs

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

# car hire costs

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