Help with 4.transportation


def hotel_cost(nights):
return 140*nights
def plane_ride_cost(city):
if city=="Charlotte":
return 183
elif city=="Tampa":
return 220
elif city=="Pittsburgh":
return 222
return 475
def rental_car_cost(days):
cost = 40 * days
if cost >= 7:
return cost -=50
elif cost >= 3:
return cost -=20
return cost
*File "python", line 15 ( return cost -=50)
return cost -=50
SyntaxError: invalid syntax


You can't return and do math in the same line, you need to split it:

cost -= 50
return cost


Hi @ari_derp123 ,

Because the code that you posted is not formatted, it is difficult for other users to read and debug it. After code has been pasted into the editing window for posting, you can format it by selecting it, and then by clicking the </> button above the editing area. Alternatively, you can place three backquotes on the line before the code and three backquotes on the line after the code. This will enable us to see important details, such as the indentation and underscores. If you use the backquotes, your code will be color-coded, making it especially easy to read.

The error is that you have included assignment operators in your return statement. Instead of ...

return cost -=50

... do this ...

return cost - 50

... or follow @stetim94 's example.

You also need to fix this one ...

return cost -=20

The conditions also need to be revised. Test the value of days, not cost. For example, you have ...

if cost >= 7:

... but should have ...

if days >= 7:


There are multiply's ways you could solve this, i like your solution better @geomaticmashups


it did not work for me


And now you expect us to fix it with just that? what do you think we are? Magicians? If you need help, post your code. You have no idea how frustrating it is, what you just did....