Taking a Vacation 4. Please help!


Below your existing code, define a function called rental_car_cost with an argument called days.
Calculate the cost of renting the car:
Every day you rent the car costs $40.
if you rent the car for 7 or more days, you get $50 off your total.
Alternatively (elif), if you rent the car for 3 or more days, you get $20 off your total.
You cannot get both of the above discounts.
Return that cost.
Just like in the example above, this check becomes simpler if you make the 7-day check an if statement and the 3-day check an elif statement.

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

What's wrong?

rent = 40 * cost

cost is not defined. Use days.

return rent


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