Help on "hey, you never know"


#1

Please Help me

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
def rental_car_cost(days) :
cost = 40 * days
if days >= 7 :
cost -= 50
elif days >= 3 :
cost -=20
return cost
def trip_cost(city,days,spending_money) :
return (rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)) + spending_money(days)
print trip_cost("Charlote",6,10)

Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Take a look at the console window for the error message from the interpreter.

Traceback (most recent call last):
** File "python", line 21, in **
** File "python", line 20, in trip_cost**
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'


#2

Hi @supremeleader123 ,

It is important to format code when you post it. That enables users to see your indentation and other important details.

See How do I format code in my posts?.

You have ...

print trip_cost("Charlote",6,10)

Where's "Charlote"?

You also have ...

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

The name, spending_money, does not refer to a function, but you have function call syntax there.


#3

thanks, it works now


#4

hi marco
the answer is :
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
def rental_car_cost(days):
total = (days * 40)
if days >= 7:
total = total-50
elif days >= 3:
total = total-20
return total
def trip_cost(city,days,spending_money):
return rental_car_cost(days) + hotel_cost(days) +plane_ride_cost(city)+spending_money


#5

shame on you @paolo060314


#6

screw you supremeleader123


#7

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