Passed the exercise but the function is not working properly


I’m not sure whether I did something wrong. I’ll like to believe that I did this exercise correctly, yet when the function is executed with 7 as the argument I get 230 as the answer which is the incorrcect answer. Is there something I am not seeing?

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


7 days already earns you 50$ discount, so 7 * 40 - 50 results in 230, so that seems right


I see where I went wrong. When I used 6 as the argument it gave me 220 as the answer. So I just naturally added 40 to that and got 260, so when I subtracted 50 from that I got 210. It never occur to me that 220 was a discounted price for renting the car for more than 3 days. I was applying both discounts. :sweat_smile: Thank you for helping me realize this.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.