Transportation help been stuck for over 6 hours


#1
`def rental_car_cost(days):
cost = 40*days
if days >= 7:
    cost - 50
    return cost
elif days >= 3 and days <= 7:
    cost - 20
    return cost
else:
    return cost`

returns the error "3 days returns the cost of 120 instead of 100." It's almost like "cost - 20" isn't even working at all. I replaced it with "cost - 100" and it still said it's giving 120 instead of 100. Beyond that. When I did "cost = cost - 20" it said it was giving the result of 280.

It's either bugged, or I'm missing something.

I've had to change the math formulas multiple times. I didn't follow the example the first few times and quickly realized why my ways weren't viable. so it's not like I've been dealing with this exact issue for so long.


#2

The - operator computes a new value. It makes no changes to its operands, you would need to assign the result somewhere or use it immediately.


#3
`def rental_car_cost(days):
cost = 40*days
if days >= 7:
   seven_discount = cost - 50
   return seven_discount
elif days >= 3 and days <= 7:
    three_discount = cost - 20
    return three_discount
else:
    return cost`

with that in mind I used this code and it worked instantly.

ninja edit: Thank you.


#4

I keep getting invalid syntax on line 15 little help plz


#5

We can't see what's on your line 15. Can you paste your code? Put three backticks on the line before it, and three more on the line after it so we can see indentation, too.

```
^ These are backticks.

#6

never mind i found my problem, i forgot to indent


#7

This is the correct input:

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