Rental car


#1




im not sure what i do here - what do i do to return the cost?


def hotel_cost(nights):
    return 140 * nights

def plane_ride_cos(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):
        if days >= 7:
           cost = (days * 40) - 50  
        elif days >= 3:
             cost = (days * 40) - 20


#2

you could do:

if days >= 7:
    cost = (days * 40) - 50 
    return cost

and the same for elif, but this means you also need an else clause for less then 3 days.


#3

Thanks!!!! It worked!!!!


#4

using the structure of the example:

def finish_game(score):
    tickets = 10 * score
    if score >= 10:
        tickets += 50
    elif score >= 7:
        tickets += 20
    return tickets

would be a more efficient method/approach


#5

yes but i tried and it didn't really work - it has now though


#6

good it works now, if you do it right it will work :slight_smile:


#7

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