# 6/7 help

#1

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 "Write a name of the city"
def rental_car_cost(days):
cost = (40 * days)
if days >= 7:
cost = (40 * days) -50
elif days >= 3:
cost= (40 * days) -20
return cost
def trip_cost(city, days, spending_money):
spending_money = trip_cost
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

What's wrong with the code? I keep getting this error :
Oops, try again. trip_cost('Pittsburgh', 4, 20) returned 922 instead of the correct value 942

#2

You are not returning your spending money at the end, and you do not need to declare it in the function either.

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

#3

It worked when I wrote as below. Compare it with yours.
I tired to make a new function that takes spending_money as an argument, like

``````def extra_cost(spending_money)
return  spending_money``````

but, when I did, it didn't work.

It showed "Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Take a look at the console window for the error message from the interpreter."

Probably because that I wrote that function wrong or it was not right for the answer as codecademy set.
I am glad I am passed, but want to know why making new function didn't work.

``````    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, spending_money):
return hotel_cost(days) + rental_car_cost(days) + plane_ride_cost(city) + spending_money``````

#4

Here's what worked for me

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