rental_car_cost


#1

what is wrong with this?

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


#2

HI try that in this part

elif days >= 3 and days <= 7:

try to remove and days <= 7
And you dont need elif days < 3:


#3

same error... "did you create function...."


#4

Hi it's easy if you save the rental in a variable like that

rent_car = days * 40

2
if you rent the car for 7 or more days, you get $50 off your total.

if  days >= 7 : 
    return rent_car = rental_car - 50

Alternatively (elif), if you rent the car for 3 or more days, you get $20 off your total.

elif days >= 3 : 
   return rent_car = rental_car - 20

You cannot get both of the above discounts.
Return that cost.

return rent_car

So all your code should be like that

Spoiler warning

def rental_car_cost(days):
    rent_car = days * 40
    if  days >= 7 : 
        rent_car = rental_car - 50 
    elif days >= 3 : 
        rent_car = rental_car - 20
    return rent_car


#5

I pretty sure that your code is wrong ... without need for running it first...:grin:


#6

Try and let me know.


#7

just did... it threw an error of some kind too

where did rental_car came from?


#8

I create rent_car and Save The the rental car cost which is 40$ a day.

rent_car = days * 40

What is the error?


#9

you got there rent_car and rental_car

it said the usual "Your code is bit off bla bla ..."


#10

Hi its the Same as

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

The code that I gave you the erro was the returns


#11

this is pretty much what I had there from the beginning. I think there is no need for brackets around days * 40 because multiplication beats addition anyway. Keeps saying "Did you create a function called rental_car_cost?"


#12

Can you post your new code.


#13


#14

Remove theelse statement
And keep return days * 40

And indent it like that

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

#15


#16

Can you copy that

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

Edit : s


#17

....this is bit off topic but ...do you have any idea why is my profile half English and half Spanish? In settings I se the profil language to English .. I can't speak Spanish (or at least I think that it's Spanish)


#18

why do you have day on the last line?


#19

I don't know why but , the instructions are they in English? If they are try to refresh the page.


#20

instructions are in English, just error messages are part Spanish..