Taking a Vacation - Question 4


#1


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

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

An error message occurs:

Oops, try again. It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.

I can't understand where I've gone wrong! I've put "-20" afterwards but it doesn't seem to work?

Thanks!


Replace this line with your code.


#2

You have to add an else to the code.

But it should correctly calculate cost for 3 days.

Try to:

  1. copy your code;
  2. click reset code;
  3. click save & submit code;
  4. paste your code back into the editor;
  5. click save & submit code.

#3

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


#5

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