4. Vacation


#1



Oops, try again. It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.


why am i getting that error?


                         

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


#2

a function ends the moment a return keyword is reached

so your function never reaches the part/code where discount is applied


#3

def hotel_cost(nights):
        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 rental_car_cost(days):
    
    price = 40 * days
    
    
    if days >= 7: 
        price -= 50
        
    elif days >= 3:
        price -= 20
        return price

new error: Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (40) for 1 days.


#4

None is the default returned by functions, so it indicate the return keyword isn't reached for days=1, currently the return keyword is only reached when elif condition is true


#5

A post was split to a new topic: 4. vacation


#6

to @javajumper31184

use the example format for it .
at the top of instructions

or just put the "return price" at the bottom of your function rental_car_cost

welcome ^^


#7

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