def hotel_cost(nights):
return nights140
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):
total=days 40
if days>=7:
total=total-50
elif days>=3 and days<7:
total=total-20
return total
def trip_cost(days, city, spending_money):
rental_car_cost(days)+plane_ride_cost(city)+spending_money
I keep getting an error similar to this:
Oops, try again. trip_cost(‘Tampa’, 6, 0) raised an error: unsupported operand type(s) for -: ‘str’ and ‘int’
I also have all of the proper indentions.
Hi here
def trip_cost(days, city, spending_money):
rental_car_cost(days)+plane_ride_cost(city)+spending_money
You missing
hotel_cost(days)
such as this?
def trip_cost(nights,days,city):
nights+days+city+spending_money
No like that
def trip_cost(days, city, spending_money):
return rental_car_cost(days)+plane_ride_cost(city)+ hotel_cost(days) + spending_money
Oh, I see. I wasn’t aware I forgot to add in a ‘return’.
thank you!
now it’s saying
Oops, try again. trip_cost(‘Los Angeles’, 7, 0) raised an error: global name ‘nights’ is not defined
def hotel_cost(nights):
return nights140
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):
total=days 40
if days>=7:
total=total-50
elif days>=3 and days<7:
total=total-20
return total
def trip_cost(city,days,spending_money):
return hotel_cost(nights)+plane_ride_cost(city)+rental_car_cost(days)+spending_money
Here inside hotel_cost(here)
you should put days
like that
hotel_cost(days)
p4p1lio
February 17, 2016, 7:37pm
8
Héy Men,
this your code for solve this step:
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):
amount = 40 * days
if days >= 7:
amount -= 50
elif days >= 3:
amount -= 20
return amount
print rental_car_cost
def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
Hi why you have this part?
def cube(n):
And in which lesson are you?
Hi there
This is how the code is suppose to be for trip cost:
for trip_cost(city,days,spending_money): #Have 3 arguments
return spending_money + hotel_cost(days)+ plane_ride_cost(city)+ rental_car_cost(days)
include spending money , hotel cost, plane ride cost and rental car cost in the body of the function
print trip_cost(“Tampa”,7,67)
**test as a sample run (use in this format to avoid concatenation error) .Its format is (city,day,spending money). The string (city) must always be first to avoid concatenation error **
Hope this helps !
Hey, I’m not here to talk about coding i just want to ask you guys a pair a questions, pls:
Do you how to delete a post? plz tell me.
Have you guys seen my post? it’s called “HEY, YOU NEVER KNOW! [project]”
Hey guys, can you PLEASE PLEASE help me. This is what I have:
def hotel_cost(nights):
return 140.0 * 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 = days * 40
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost
def trip_cost(city, days):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)
It keeps telling me: “Oops, try again. trip_cost should take exactly 3 arguments!”
hey guys, i dont know why but i keep receiving and error saying trip_cost() takes exactly 3 arguments (2 given). i have 3???
def hotel_cost(night):
return 140*night
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 0
def rental_car_cost(days):
if days >= 7:
car_rent = (days40) - 50
return car_rent
elif days >=3 and days <= 7:
car_rent = (days 40) - 20
return car_rent
else:
car_rent = days*40
return car_rent
def trip_cost(city,days,spending_money):
return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days) + spending_money
print trip_cost(‘Tampa’, 4)
I’m getting this message : Oops, try again. trip_cost(‘Tampa’, 2, 0) raised an error: ‘int’ object is not callable
Which is perplexing because I haven’t seen this error in the previous lessons.
For reference, my code looks like this:
def hotel_costs(days) :
return 140nights
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
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,spending_money):
return rental_car_cost(days)+hotel_cost(days)+plane_ride_cost(city)+spending_money(days)
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=days*40
if days>=7:
return cost-50
elif days>=3 and days <7:
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
1 Like
This still doesn’t work, it’s saying Oops, try again. Oops! Did you accidentally delete the trip_cost function?
becon12
February 28, 2017, 3:05pm
20
def hotel_cost(nights):
hotbill = 140 * nights
return hotbill
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:
cost -= 50
return cost
elif days >= 3:
cost -=20
return cost
else:
cost +=0
return cost
def spending_money(cash):
if cash > float(0):
return cash
else:
cash=float(0)
return cash