Printing the output


The following code is good and came out without errors BUT

These are my questions.

1.) How can i see the output. For example in this case i would like to see the total cost of the trip (which includes LA, 5 nights and $600). it looks the print function in the program prints the results internally. Is there a way to display the results.

2.) i would like to tinker the code such a way that i get an option (after running the prog) to enter city, day and spending amount. Thus getting the final cost. I need this forum help on this too.

Thanks for the help

def hotel_cost (nights):
    return 140*nights

def plane_ride_cost (city):  
    c = 183
    t = 220
    p = 222
    m = 475
    if city == "Charlotte":
        return c
    if city == "Tampa":
        return t
    if city == "Los Angeles":
        return m
    if city == "Pittsburgh":
        return p
    else :
        return "Not a valid destination."

def rental_car_cost (days):  
    cc = 40*days #Every day you rent the car costs $40.
    bd = cc-50      #if you rent the car for 7 or more days, you get $50 off your total.
    sd = cc-20      #if you rent the car for 3 or more days, you get $20 off your total.
    if days >=7 : 
        return bd
    elif days >= 3 and days <7:
        return sd
        return cc
def trip_cost (city,days,spending_money): 
        sum = rental_car_cost(days) + hotel_cost(days)+ plane_ride_cost(city)+spending_money
        #It is completely valid to call the hotel_cost(nights) function with the variable         #days
        print trip_cost("Los Angeles", 5, 600)
        return sum


well, a function call executes the function so it should be placed outside the function:

def example():
     return "See how this works?"

print example()


following this logic, inserting the prompts is relatively easy. Simply prompt the user 3 times (using raw_input(), which you already learned), store the result of the prompts in variable (nothing new here either)

then supply the variable (which contain result of prompts) as argument on function call

for the argument that are integers, don't forget to convert the input to integer (int()), raw_input stores the result as string


yesssssss :). Thanks a lot. Got it. did that and worked

Really appreciate your help