I dont get how it is wrong


#1

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

def trip_cost(city,days,spending_money):
    return hotel_cost(days)+plane_ride_cost(city)+rental_car_cost(days)+spending_money
print trip_cost("Los Angeles", 5, 600)

WHY DOESNT IT WORK


#2

here:

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

your rental_car_cost doesn't return anything if i rent the cars for one or two days


#3

it still doesnt work


#4

i only showed you where you went wrong, you still have to fix it.


#5

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

is this wrong aswell


#6

yep, i put the code here, as you can see, for two days None is returned instead of the correct 80


#7

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

def trip_cost(city, days, spending_money):
    return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days) + spending_money

print trip_cost("Los Angeles", 5, 600)

This is my code now but it is still wrong


#8

The code i show highlights where the issue is, you still have to code the fix

You can't just copy and paste my code, that won't work.


#9

try
cost -= 20
cost -=50
instead :slight_smile:


#10

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