Transportation: Taking a Vacation


#1



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

errors:
Syntaxerror 'return' outside function line 21


Please tell me what is wrong here


Replace this line with your code. 
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
    elif city == 'Los Angeles':
        return 475
    else:
        return 'Price Unknown'

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


#3

What is wrong is how the rental_car_cost(days) function has been indented. The way you have done that one, Python thinks that everything from the if days ... line on down is outside the function. This means your program is not going to give you the results that you expect and that Python is going to complain about having a return statement outside of a function.

Take your time and indent so that everything that should be inside the function is. Your first two functions are done correctly.


#4

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