Pull it together


#1



def hotel_cost(nights):
    nights = input("Koliko noci")
    one_night = 140
    return one_night*nights
    
def plane_ride_cost(city):
    city = input("Unesite grad")
    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):
    if days < 3:
        return 40*days
    elif days >= 3 and days < 7:
        return 40*days - 20
    else:
        return 40*days - 50
        
def trip_cost(city, days, nights):
    return rental_car_cost(days), hotel_cost(nights)+plane_ride_cost(city)


#2

Your trip_cost function should only have two parameters city and days.


#3

It still doesn't work..
I tried it like you said and the message is: Oops, try again. hotel_cost(1) raised an error: unexpected EOF while parsing (, line 0)


#4

could you post an updated version of your code?


#5

def hotel_cost(nights):
    nights = input("Koliko noci")
    one_night = 140
    return one_night*nights
    
def plane_ride_cost(city):
    city = input("Unesite grad")
    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):
    if days < 3:
        return 40*days
    elif days >= 3 and days < 7:
        return 40*days - 20
    else:
        return 40*days - 50
        
def trip_cost(city, days):
    sum = rental_car_cost(days)+ hotel_cost(days)+plane_ride_cost(city)
    return sum

#6

please follow the instructions of the exercises, the inputs overwrite the function parameters, remove the lines which have an input, otherwise the function calls from the checking script can't validate correctly


#7

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