Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44624
| From | leonardo selmi <l.selmi@icloud.com> |
|---|---|
| Subject | help.. |
| Date | 2013-05-02 15:56 +0200 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1236.1367502996.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
i have also this program:
write a function called rental_car_costthat takes days as input and returns the cost for renting a car for said number of days. The cost must abide by the following conditions:
Every day you rent the car is $40.
If you rent the car for 3 or more days, you get $20 off your total.
If you rent the car for 7 or more days, you get $50 off your total. (This does not stack with the 20 dollars you get for renting the car over 3 days.)
so i wrote the following code:
def rental_car_cost(days):
cost = 40*days
if days >= 7:
return cost - 50
elif days >= 3 and days < 7:
return cost - 20
else:
return cost
but it seems not to be right cause the computer answers: Oops, try again! Did you create a function called rental_car_cost?
ii wrote also:
def rental_car_cost(days):
if days >= 7:
return (40*days) - 50
if days >= 3 and < 7:
return (40*days) - 20
else:
return (40*days)
they both work in python shell/idle but not in the exercise in "codecademy"..what do you think? is there a bug?
thanks!
kindest regards
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
help.. leonardo selmi <l.selmi@icloud.com> - 2013-05-02 15:56 +0200
csiph-web