Why wont this return properly?!?!


#1

I've been trying to complte this exercise for two days now and i still can't complete it even with numerous help from this forum anyway heres my code:

def hotel_cost(nights):
return nights * 140

def plane_ride_cost(city):
city = city.lower
if city == 'Charlotte':
plane = 183
elif city == 'Tampa':
plane = 220
elif city == 'Pittsburgh':
plane = 222
elif city == 'Los Angeles':
plane = 475
else:
print 'You have entered an invalid city name'

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):
return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days)
print trip_cost(tampa, 10)

and heres the error:

Oops, try again. plane_ride_cost('Charlotte') returned None instead of the correct value 183


#2

Remove the following line...

city = city.lower

#3

You've used city.lower to put the string city into all lower case but then you're checking it against names with a caps. So if the users entered Charlotte you're turning it into charlotte. As suggested above getting rid of city = city.lower will be a quick fix but things like chaRlotte and cHarlotte or CHARLOTTE wont match so for the sake of integrity it's better to keep city=city.lower and change the strings your checking for to all lower case as below:

def plane_ride_cost(city):
city = city.lower
if city == 'charlotte':
plane = 183
elif city == 'tampa':
plane = 220
elif city == 'pittsburgh':
plane = 222
elif city == 'los angeles':
plane = 475
else:
print 'You have entered an invalid city name'

#4

We should work with the data given in the instructions. Getting distracted over letter case is a diversion away from the main point in the lesson.