Pull it Together


#1



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


Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Take a look at the console window for the error message from the interpreter.


I need help with the lesson.


Replace this line with your code. 
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
    
    plane_ride_cost("Tampa")  

def rental_car_cost(days):
    cost = 40*days

    if days>=7:
        cost -= 50

    elif days >=3:
        cost -= 20

    return cost

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


#2

uh when will anybody reply


#3

I'm not sure why you added that but it isn't needed. That's what trip cost function is about. Delete it.


#4

i fixed it but it still shows the same error

Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Take a look at the console window for the error message from the interpreter.


#5

Also your indents look a bit off on some of your code...you might want to check them.


#6

this is how my code looks like right now


Replace this line with your code. 
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
    
    plane_ride_cost("Tampa")  

def rental_car_cost(days):
    cost = 40*days

    if days>=7:
        cost -= 50

    elif days >=3:
        cost -= 20

    return cost

def trip_cost(city,days)
    return rental_car_cost(days) + hotel_cost(day


#7

Yeah...the indents are wrong, give me a second to fix it, and give you the right code.


#8

ok i fixed the "return" on the top


#9

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
    
plane_ride_cost("Tampa")  

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

def trip_cost(city, days):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
    
trip_cost("Tampa", 3)

Even though I took out a bunch of space between you if, elif statements, they do absolutely NOTHING to your code. The only thing that effects your code is the indents which I have fixed in this code. :slight_smile:


#10

ok thanks i will take a look at the codes


#11

Did it work for you? Welcome. :slight_smile:


#12

yeah they worked out for me


#13

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