Python Lesson: Taking a Vacation (4/7) [Transportation]


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

Error: “It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.”


#2

days -= 50

what did you expect to get if you subtract 50 from days?

Instruction:

if you rent the car for 7 or more days, you get $50 off your total

so if you subtract 50 from days will you get the result( 50 off ) what you want?

you are returning cost form the function what is always same without consideration for days.


#3

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