Transportation


#1



https://www.codecademy.com/courses/python-beginner-P5YtY/1/3?curriculum_id=4f89dab3d788890003000096#


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
    else:     
        return cost


#4

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
else:
return rental


#5

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


#6

i updated it but still am getting an error message


#7

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


#8

please explain why i would use and instead of or


#9

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


#10

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


#11

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


#12

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:


#13

oh thanks that worked!


#14

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