Taking a vacation


#1

day_rate = 40
no_of_days = input()
toatal_amount = no_of_days * day_rate
if no_of_days * day_rate >= 280:
    print "50$ discount applicable and amount is: " total_amount-50
elif no_of_days * day_rate >= 120 and no_of_days * day_rate <= 240:
    print "20$ discount applicable and the amount is: " total_amount-20
else:
    print total_amount

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

File "python", line 10
print "50$ discount applicable and amount is: " total_amount-50
^
SyntaxError: invalid syntax

Hi Guys,

IF i enter 2 in the output window, it is suppose to give the total amount. where does it gone wrong? and also if i enter 4 in the output, it should show the total amount-20$. Where does it gone wrong? your help will be much appropriated.

Replace this line with your code.

`


#2

You are overthinking this. Please reread the instructions. They tell you exactly what to do...


-----------------------------------------------------------------[ Instructions: ]----------------------------------------------------------------
01. Below your existing code, define a function called rental_car_cost with an argument called days.

02. Calculate the cost of renting the car:

-- Every day you rent the car costs $40.
-- if you rent the car for 7 or more days, you get $50 off your total.
-- Alternatively (elif), if you rent the car for 3 or more days, you get $20 off your total.
-- You cannot get both of the above discounts.

07. return that cost.

Just like in the example above, this check becomes simpler if you make the 7-day check an if statement and the 3-day check an elif statement.



#3

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

I understood @aquaphoenix17. if you are looking for the above code, i did it. But i want to do it in a different way. Can you please correct the previous code?


#4

Unfortunately, codecademy's SCT is very strict on this exercise and you must do it the way the instructions intended in order to move on with the lessons.

But nevertheless, the problem with your code is in your print statements. You need to include a + between your strings and the values, like this:

print "50$ discount applicable and amount is: " + total_amount-50

#5

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