Hey, You Never Know! (6/7)


#1

I don't understand what I have done wrong here.
This is my code:
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:
cost -= 50
elif days >= 3:
cost -= 20
return cost
def trip_cost(city, days, spending_money):
return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days)

However, when I run it, this error shows up:
Oops, try again. trip_cost('Tampa', 2, 57) returned 580 instead of the correct value 637

What should I do?
(Sorry if this sounds stupid because it's probably really easy to solve.)


#2

Never mind everyone! I HAVE FIXED THE ISSUE! :smiley:


However, if any of you are struggling, here's the solution (remember to use indentation so the console doesn't start shouting at you for getting something wrong.):
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:
cost -= 50
elif days >= 3:
cost -= 20
return cost
def trip_cost(city, days, spending_money):
return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days) + spending_money


Santiago pls explain how your correct the error, some of us still stock in it :(