Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Your code threw the following error: invalid syntax (python, line 18)

please explain what is wrong

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


You are defining both discounts. You need the 3 to 6 days with 2 conditions >>

def rental_car_cost(days):
rental = 40 * days
if days >= 7:
return rental - 50
elif days >=3 and days < 7:
return rental - 20
return rental


Let me know if this helps. If you have questions I will do the best I can to answer them.


i updated it but still am getting an error message


Make sure you have the proper indentations as well. and you used "or" instead of "and"


please explain why i would use and instead of or


on the elif line the conditions have to both be True so you need the and function where as the or function reads as one of the other


oh ok, i still got an error though, the same one


it is pointing at the less than sign behind the 7 on line 18


The code reads the syntax on either side of the and separately. So you need to put days on both sides of the condition. so you needs:

elif days >= 3 and days < 7:


oh thanks that worked!


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