# Pull it together - cannot make code run properly

#1

Pull it together section 5

Oops, try again. trip_cost('Tampa', 8) returned 1390 instead of the correct value 1610

I'm really stuck, not sure where the problem is in my code? any help greatly appreciated... seem to be a problem with my trip_cost

``````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:
return cost - 50
elif days >= 3:
return cost - 20
else:
return cost

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

#2

def trip_cost(city, day):
return rental_car_cost(days) + hotel_cost(days)
+ plane_ride_cost(city)
In the sum of return founction : there is no empty before the newline**+ plane_ride_cost(city)**, also means no need to do left-justified before starting a newline. Or else, the plane_ride_cost will beyond the sum.

#3

@dthden66

In the `rental_car_cost(days)` there seems to be problem. Instead of returning the value of cost taking out the discount, you should be setting the value of cost with the discount like this:

``````#This is just an example
#Let's say the value of the discount is 30
#We set cost variable to a new value after discount
cost -= 30``````

Remove your else statement. You should be returning the cost for all of the conditions anyways.

#4

only the founction word--"return" left-justified with "def" will ok

#6

your error is the left spacing, remember Python is literal.
Should be
def trip_cost(city,days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

#7

i think you've got to change the

def hotel_cost(days):
return 140 * days

this code works...

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):
cost = days * 40
if days >= 7:
return cost - 50
elif days >= 3:
return cost - 20
else:
return cost
def trip_cost(city, days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

#8

with proper indentation of course...