Taking a Vacation 4. Please help!


#1

Question:
Instructions
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.

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

What's wrong?


#2
rent = 40 * cost

cost is not defined. Use days.

return rent

#3

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