Taking a vacation tranportation help please


#1



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


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


#2

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


#3

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


#4

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?


#5

they didnt tell me to make a variable named cost no


#6

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


#7

I just changed it and it still says the same thing


#8

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.


#9

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


#10

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..


#11

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


#12

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


#13

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


#14

@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:


#16

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.


#17

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