Review Function stuck! Please assist


#1


#2

It's very difficult to read your code, zoom in and take a picture, or even better post your code. :slight_smile:


#3

Your problem is your if/elif statements. You aren't putting yes and no inside of strings, but assuming that they're variables, which they're not. You neeed to compare to strings. :slight_smile:


#4

Thank you, so much....You are really helpful!!!!!!:slight_smile:


#5

Am kind of having another small huge stuck!!!!lol


#6

Hi, thanks for the the previous and am stuck again...
on transportation:

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
    else:
        return "select city"
def rental_car_cost(days):
    cost = 40 * days
    if days >= 7:
        cost = 40 * days-40
    elif days >= 3:
        cost = 40 * days-20
    else:
        return cost

it is saying:Oops, try again. It looks like rental_car_cost returns None instead of the correct amount (100) for 3 days.

could you give me a hand with this one? Sorry for bothering.....


#7

if days are greater then 3, a return keyword is not reached. Just return cost at the end of your function, without else


#8

Isn't the way i put return cost at the end right?


#9

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

#10

None

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


#11

now a return keyword is only reached if elif is true, so now only if days are more then 3 and less then 7, what about more then 7 and less then 3?


#12

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