Error on 7/7


#1

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

My code 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):

cost = days * 40

if days >= 7:
    return cost - 50

elif days >= 3:
    return cost - 20

else:
    print "Please enter a number of days" 
return cost

def trip_cost(city, days, spending_money):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money

print trip_cost("Los_angeles", 5, 600)


#2

I have fixed the "Los_Angeles" / "Los Angeles" error but that did not fix the issue.


#3

Hey, make sure you don't indent the print line at the end, If that works let me know.


#4

@microace90767 sorry it doesn't work i just tried
unless my code isn't exactly like his


#5

def hotel_cost(nights):
return 140.0 * 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):
return cost - 50
elif(days >= 3):
return cost - 20
else:
print trip_cost("Los Angeles",5,600)
return cost

def trip_cost(city, days, spending_money):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money


#6

that should work!! :smile:


#7

if you want to print it on screen you have to keep all whitespaces IT'S VERY IMPORTANT!!
my code looks like

def trip_cost(city, days, spending_money):
return (rental_car_cost(days) + hotel_cost(days)
+ plane_ride_cost(city) + spending_money)
print trip_cost("Los Angeles", 5, 600)