Hey, You never know.... help please


#1

I don't know what I am doing wrong here.
This is my code:
def hotel_cost(nights):
return 140*nights

def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475
elif city == "Tampa":
return 220

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

def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
print trip_cost ("Tampa", 5)

And I am getting this error:
Traceback (most recent call last):
File "python", line 27, in
TypeError: trip_cost() takes exactly 3 arguments (2 given)

Please help me.


#2

You defined it with three arguments, but passed two when you called it.


#3

or simply, here's the answer
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 < 7:
return days * 40 - 20
else:
return days * 40

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


#4

I can help you. In your function "def trip_cost(city, days, spending_money)"
you said your are going to give three variables (city, days and spending_money).
at the the end of your code, you called your function and when people say "call a function" they mean start your function.
So at the end you only gave two arguments.
1. city, which you put as "Tampa"
2. days which you put as 5
3. you were supposed to put in spending money which you did not.
the code supposed to look like this.
print trip_cost("Los Angeles", 5, 600)
as you can see I put in a third variable.
if you have any questions just ask me.:slight_smile: