Transportation Code error


Transportation -

File "python", line 18
return total=total - 50
SyntaxError: invalid syntax

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


You do not need to return this, just

return total - 50

Also do this for this line:

additionally, why are you indented so much? Python is EXTREMELY meticulous about indenting, so shift+tab everything inside of the function rental_car_cost.


now the code gives error " Did you create a function called rental_car_cost?" :frowning: I do indent to make it readable for me ( I'm new in coding)

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


No, it's good to indent, I'm saying you indented one indent too far lol.
I think your only problem is that you don't have else statement... Your code should look like a variation of this:

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


same error - "Oops, try again. Did you create a function called rental_car_cost?" I don't get it, I have defined the function :expressionless:


refresh, try again. try a new browser maybe?


Yeah . tried Edge didn't work there , Tried refresh ... same .


Aha! On line 15, you need to make sure that rental_car_cost is NOT inside of plane_ride_cost. Only the function start is indented, so leave the rest alone. :slight_smile:


You made my life so much easier :smile: Ty


No problem! Glad you got it figured out!


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