Please what am i not doing right


#1

Continuing the discussion from Hey, you never know!:

Continuing the discussion from How to loop Pig Latin Translator, when incorrect input entered?:



def hotel_cost(nights):
    # If hotel cost $140/night...
    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
    else:
        return 0
        
def rental_car_cost(days):
    cost = 40 * days
    if days >= 7:
        cost -=50
    elif days >= 3:
        cost -= 20
    return cost
    
def souvenirs(spending_money):
    #if spending money is $50/day...
    return 50 * spending_money
    
nights = raw_input("Enter the no of nights")
def hotel_cost(nights):
    return 140 * nights
city = raw_input("Enter the city name:")    
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):
        return total - 50
    elif(days>=3):
        return total - 20
    else:
        return total
def souvenirs(spending_money):
    return 50 * spending_money
def trip_cost(city, days, spending_money):
        return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + souvenirs(spending_money).


#2

It returns the error "Oops, try again. trip_cost('Pittsburgh', 5, 78) returned 5002 instead of the correct value 1180".


#3

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