I'm learning python and I don't seem to understand why my code is wrong.
def rental_car_cost(days):
rent = 40 * days
if days >= 7:
rent -=50
elif days > 3 and days < 7: # is this allowed in Python?
rent -=30
return rent
I just want to do this 3 < days < 7
I tried to search for if statements syntax but couldn't find an answer for this online. What I'm trying to accomplish is very simple if days the argument days is more than 7 then rent = rent - 50, and if days is more than 3 but less than 7, then rent = rent - 30.
def rental_car_cost(days):
rent = 40 * days
if days >= 7:
rent -=50
elif days > 3 and days < 7: # is this allowed in Python?
rent -=30
return rent
The error says the function rental_car_cost is not defined ...
Aucun commentaire:
Enregistrer un commentaire