Transportations


#1

0

not working ...help me why

def hotel_cost(nights):
nights == '$140'
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 rentalCarCost(days):
totalCarCost = days * 40
if (days < 3):
return totalCarCost
elif days >= 3 and days < 7:
return totalCarCost - 20
elif days >= 7:
return totalCarCost - 5


#2

Here what my code looked like:

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

return cost

Hope that helps


#3

I was stuck for a long time before I found out that my last "return" was mis-indented. Here is the correct code which is working fine:

Calculate Car Rental Cost

def rental_car_cost(days):
rent = days * 40

if days >= 7:
    rent -= 50
elif days >= 3:
    rent -= 20
return rent

print rental_car_cost(8)


#4

This topic is barely readable, and considering how important format is in Python, needs proper markdown on code samples. Everybody posting in this thread needs to read and learn the techniques for posting code in text and in blocks. Search in the Meta category for 'three back ticks'.