Taking a vacation- 4 Transportation


#1



File "python", line 22
SyntaxError: 'return' outside function


Anyone know whats wrong with this


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


#2

Hi, @enigmaticgenius ,

Proper indentation is essential in Python. The entire content of the function body must be indented with regard to the function header.


#3

i believe you need to return total for each statement like so:

if days >= 7:
return total - 50
elif days >= 3 and days < 7:
return total - 20
to end it I added an else where it simply returned the total


#4

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