Transportation help


#1

Hello can someone help me?

They say that if i put in 1 day it would give me 20.

Sorry my English is very bad.


#2

or doesn't work that way, what you have there will always be considered true, because 160 is non-zero (truthy)
200 and 240 are not considered at all, since 160 is already truthy

by truthy I mean that bool(160) evaluates to True


#3

def rental_car_cost(days):

if days >= 7:
    return 40*7-50
elif days >=3:
    return 40*3-20
else:
    return "correct amount(40) for 1 day"

Error is "Oops, try again. It looks like rental_car_cost returns 'correct amount(40) for 1 day' instead of the correct amount (40) for 1 days.

whats wrong here


#4

Hi
first off all

in calculations which you make in returns you should use variables instead numbers. In this form no metter for how many days you rent the car this function will always give you the same answer ( for e.g. if you rent car for 10 days return should be 350 [10 days * 40 price - 50] but you will still get 230.

About your error - in else: return, just like in previous returns you want to get number, not a string (sentence).


#5

Dear suresh, please do not post your queries in multiple places. Doing so will not get you answers quicker but hinder us in providing solution to the original poster (who currently is @ayoubr). I see that you have asked a question here which is the correct way to get answers to your question. In fact, I was the one who answered it and it's now solved as well :smile:

Thanks!