7/7 help


#1

Help v
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):
cost = 40 * days
if (days >= 7):
return cost - 50
elif(days >= 3):
return cost - 20
else:
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)


#2

Please re-edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.


#3

This Works
Just Indent after a colon

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


#4

@matthew_maya_17,

Please re-edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.


#5

this is my code..and it's work..hope can help you

def hotel_cost(nights):
    hotel_cost = 140 * nights
    return hotel_cost
    
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
    elif days < 3:    
        return cost    
        
def trip_cost(city, days, spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money            
print trip_cost("Los Angeles", 5, 600)

the solution is to put print trip_cost back one level...alhamdulilah..it's work 4 me..


#6

do you respond to these things all day?
I have seen you on every language. Do you program for a living?


#7

i have tried the above and still get the same error: "oops, did you forget the cost_trip function"


#8

def hotel_cost(days):
hotel_cost = 140 * nights
return hotel_cost
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 "wrong answer"

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

def trip_cost(city, days,m):
rental_car_cost(days)
hotel_cost(nights)
plane_ride_cost(city)
spending_money = m

trip_cost = rental_car_cost(days) + hotel_cost(nights) + plane_ride_cost(city) + spending_money 
print trip_cost("Los Angeles", 5, 600)

THE SAME ERROR MESSAGE CONTINUED TO APPEAR: "did you accidentally delete the trip cost function" . this is very frustrating, please, kindly help.

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

#10

It always amazes me how something as simple as indentation can make the whole code not work! Thanks for your help.


#11

Thanks soo much! I really needed this I was about to loose my mind.


#12

def hotel_cost(nights):
#hotel cost per night is $140
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):
amount=days*40
if days>=7:
amount-=50
elif days>=3 and days<7:
amount-=20
return amount
def trip_cost(city,days,spending_money):
return rental_car_cost(days)+hotel_cost(days)+plane_ride_cost(city)+spending_money
print trip_cost("Los Angeles",5,600)

This one works with no error.In case anyone struck in this level you may get idea by looking at this code .All d best.


#13

any one got a help with the above code of mine..I would be thankful if it had been a support to your code stuff.I expect the glance at the code would be a great luck to me..

your friend for coders


#14

@digveejay,

Please re-edit your 'code-Post'
to include the proper indentation's
http://discuss.codecademy.com/t/7-7-help/11344/4?u=leonhard_wettengmx_n


#15

@leonhard_wettengmx_n

I hope you write to correct person whom you suggest to make the changes.
have a great day my dear coders


#16

@digveejay,

As indentation is an important part of the Python-code
i suggested
http://discuss.codecademy.com/t/7-7-help/11344/14?u=leonhard_wettengmx_n

So try to edit your Original Post in such a way that you are using the right =indentations=


#17

@leonhard_wettengmx_n

Please re-edit your Post
•leave one blank-line above of your code
•select your code in the Post
•then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations