8. Taking a Vacation


#1



8. Taking a vacation


The program is giving 120 instead of 100. It seems the elif statement is not firing or something, it looks right but its not working. Any help here with the solution.


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

Replace this line with your code.


#2

look at this code:

i = 5
print i # 5
print i + 5 # 10
print i # 5
i = i + 5 
print i # 10

what you do, doesn't update cost, it just temporary decrease cost, like you can see in the example above


#3

I don't understand, as far as I can tell my code does, still confused what your trying to say.


#4

here:

cost - 20

this will not decrease cost (apply discount) as it should, i showed you in the example why it doesn't. Without using = you won't update/re-assign a variable


#6

I added the cost = cost - 50 and still wrong so I'm at a loss what to do. Its not updating cost. Looked back to the >=<=+- etc .. conversions and nothing is =- its just plain -, I dont understand what im suppose to write here to update the code when cost = cost - 50 / 20 isnt working.


#7

can i see an updated version of your code?


#8

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