TAV - Trasportation


#1



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


I've tried every way and still comes out incorrect so I really dont kow what i'm doing wrong. I see other posts where people did the same exact things I did and it worked for them. Really need some help cause I'm on a deadline to learn this language. Thanks in advace.

Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.

and with the -=50 and -=20 i get:
Oops, try again. 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: can't assign to operator (python, line 19) (python, line 17)

when i take out else before return at the bottom i get:
Oops, try again. It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.

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


#2

well, you actually need to return the cost, which you do in your else statement:

return days * cost

but you do not in your if and elif:

if days >= 7:
   /* missing return */ days * cost - 50

same for your elif, oh and one more thing, if the number of days is 1 or 2, elif will run since 1 is smaller then 7. In your elif, you want both conditions to be met (at least 3 days or more and a maximum of less then 7


#3

ok i'll try this and let you know how it work ty


#4

'''
def rental_car_cost(days):
cost = 40
if days >= 7:
return days * cost - 50
elif days >= 3 or days > 3:
return days * cost - 20
return days * cost
'''
so this code was completely right! thanks for lookin out ^_^