Oops, try again. rental_car_cost(3) returned 120 instead of the correct value 100


#1

def hotel_cost (nights):
cost = (140 * nights)
return cost

def plane_ride_cost (city):
if city == ("Charlotte"):
print ("The Price = 183")
return (183)
elif city == ("Tampa"):
print ("The Price = 220")
return (220)
elif city == ("Pittsburgh"):
print ("The Price = 222")
return (222)
elif city == ("Los Angeles"):
print ("The Price = 475")
return (475)
else:
print ("Oops! city does not match")
plane_ride_cost ("Tampa")

def rental_car_cost (days):
rcc = 40*days
rcc > 0
if days >=7:
rcc = rcc-50
return rcc
print (rcc)
elif days >=3 and rcc < 7:
rcc = rcc-20
return rcc
print (rcc)
else:
return rcc
print (rcc)

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


#2

@methodplayer27108

here is an example fore you. As you can see I only compare the days once each if line. The reason for this is because if it gets past the low tier if statements we can guarantee that it is greater than x number. So we only have to compare it to the next lowest number.

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

EDIT:

You can also do this one with out variables to hold the data like the following,

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