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)
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.
1 Like
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)
@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.
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…
1 Like
do you respond to these things all day?
I have seen you on every language. Do you program for a living?
i have tried the above and still get the same error: “oops, did you forget the cost_trip function”
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.
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)
1 Like
hamish9
December 26, 2015, 9:30pm
10
It always amazes me how something as simple as indentation can make the whole code not work! Thanks for your help.
Thanks soo much! I really needed this I was about to loose my mind.
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.
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
@digveejay ,
Please re-edit your ‘code-Post’
to include the proper indentation’s
7/7 help
@leonhard_wettengmx_n
I hope you write to correct person whom you suggest to make the changes.
have a great day my dear coders
@digveejay ,
As indentation is an important
part of the Python-code
i suggested
7/7 help
So try to edit your Original Post in such a way that you are using the right =indentations=
2101175
January 19, 2016, 12:42am
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