6 Hey you never know


#1



Hi, I cant seem to figur out why this code is wrong, have used a bit of time going over and looking through the forum but cant figure it out. anyone that can help? really appreciate it :slight_smile:

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

i get the following error message:

File "python", line 29
def trip_cost(city, days, nights):
^
IndentationError: expected an indented block

this is my code:


#workout cost of hotel
def hotel_cost(nights):
    return 140 * nights
    
#workout cost of plane ride
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
    
#workout cost of car rental
def rental_car_cost(days):
    cost = 40 * days
    if days >= 7:
        cost -= 50
    elif days >= 3:
        cost -= 20
    return cost
    
#workout cost of spending money
def  spending_money(days):
    
#total cost 
def trip_cost(city, days, nights):
    return rental_car_cost(days) + hotel_cost(nights) + plane_ride_cost(city) + spending_money(days)


#2

you can't leave a function empty:

def  spending_money(days):

if you want to keep this function, simple use the pass keyword, then the function does nothing:

def  spending_money(days):
   pass

#3

ok thanks. now i get another error message! hahah

trip_cost('Los Angeles', 3, 0) raised an error: unsupported operand type(s) for +: 'int' and 'NoneType'


#4

isn't it a good idea to take a look yourself first? The topic you created was, i guess, a question you have been struggling longer with. Your reply with the new problem isn't. It can't be, it is too quick for that


#5

problem is that i dont understand the error messages. there havent really been any lessons on it so im struggling to understand what the error message means. if i understood that then i would know what part of the code is wrong and i could go about fixing it. at the momment i get an error message that is like reading greek and i dont know what part of the code is wrong.....


#6

this line:

return rental_car_cost(days) + hotel_cost(nights) + plane_ride_cost(city) + spending_money(days)

spending mony doesn't return anything (so it becomes NoneType). Maybe it is better then to let your spending money function return a number. Or remove it from the trip_cost function


#7

being Friday the 13th i thinks taking it out in my code! :stuck_out_tongue:

thanks for the help! appreciate it