Can anyone see my mistake please


#1

I am stuck on this part of the exercise, i know its some thing simple! But i just cant see the wood for the trees!!

https://www.codecademy.com/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096#

This is the error i get..

Oops, try again. rental_car_cost(3) returned None instead of the correct value 100

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 " Enter City Again"
        
def rental_car_cost(days):
    cost = 40 * days
    if days >=7:
        cost -=50
    elif days >=3:
        cost -=20
    else:
        return cost
    
def trip_cost(city, days,spending_money):
    trip_cost = hotel_cost(days)+plane_ride_cost(city)+rental_car_cost(days)
    return trip_cost
    print trip_cost('Los Angeles', 5, 600)

#2

    if days >=7:
        cost -=50
    elif days >=3:
        cost -=20
    else:
        return cost

Here, you won't be able to return cost IF days are greater 3 and 7 as well as between 3 and 7. How about removing the else: and unindent return cost?


#3

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

now returns this error

Oops, try again. trip_cost should take exactly 2 arguments!


#4

done it, i had jumped a step as well as you advice thanks very much.


#5

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