I can't find my syntax error here (Taking a Vacation), please help!


#1



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


SyntaxError: 'return' outside function


It should work just fine, but there seems to be an error at the 'return total - 50' line.


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


#2

Those lines are not indented enough, so are outside of the function code block.

The first return (line 3) should be removed.


#3

Awesome, I fixed it. Thank you! :slight_smile:


#5

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