Taking a vacation tranportation help please



says Did you create a function called rental_car_cost?
SyntaxError: invalid syntax

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


the minus for cost i think should be place before equal sign (-= like example before),
but i do stuck in the same place lol


ya i know and I do have it like that but when I put it in it reverses it


It should be - rather than =-. If they didn't teach you how to use =- , or if it wasn't in the instructions, then you don't need it. Also, did the instructions tell you to make a variable named cost?


they didnt tell me to make a variable named cost no


Then cost, isn't necessary. You should be using the rental_car_cost variable instead. :slight_smile:


I just changed it and it still says the same thing


Instructions say:

Below your existing code, define a function called rental_car_cost with an argument called days.
Calculate the cost of renting the car:

Every day you rent the car costs $40.

what should we replace all the cost variables with?
hint: don't replace them with the argument, days.


If you need more help, let me know. :slight_smile:


Your code lets me pass.

But as you mentioned this error..

SyntaxError: invalid syntax
Check if you get any indentation problem or spelled something wrong..


Yeah if you indented something incorrectly, your code won't function properly.


Im sorry, I spelled 'your' incorrectly so it looked like 'sour' instead. :sweat:


intermediate gamer I spelt everything right and checked the indentation and this is the new code
def rental_car_cost(days):
rental_car_cost = days * 40
if days >= 7 :
rental_car_cost = rental_car_cost - 50
elif days >= 3:
rental_car_cost = rental_car_cost - 20
return rental_car_cost
but it still says the same thing


@naman108 could you possibly write your code in Preformatted text so I can check for any tiny errors?:slight_smile:
I'm sorry I'm writing this late, the internet went down.:computer:


Ah, I found your error:

You should return rental_car_cost rather than saying that it =s itself. If you need more help, let me know. Basically, rental_car_cost = isnt needed. Do you know what to replace it with?
*Hint: I wrote what you need to replace it with in this post. It starts with an r and ends with an n.


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