3. Getting There: Unrelated Question


#1

3.Getting There

Hi, I have enough to get me through to the next exercise but I added a little extra to make it better, except I have a problem.
When I enter input for the first question, instead of printing the cost of the hotel 140 * (nights),
I get < function hotel_cost at 0x7f8a4f879c80 >, what do I do?

*note, I put spaces between "<" and "function" so that it would show up.

My code:

> raw_input("How many nights will you be staying for?")
> def hotel_cost (nights):
>     return 140 * (nights)
> print hotel_cost
>     
> raw_input("What city are you located in?")

> def plane_ride_cost(city):
>     if (city) == "Charlotte":
>         return 183
>     if (city) == "Tampa":
>         return 220
>     if (city) == "Pittsburgh":
>         return 222
>     if (city) == "Los Angeles":
>         return 475
> print plane_ride_cost

#2

You have two print statements. It's coming from one of them.
What are the values that you print, what do those names refer to? How do you expect that to look like when printed? What does the printed text say? Because it's telling you exactly what it is.


#3

I want it to print the result of return 140 * (nights). Let's say someone entered "3" nights, I want it to print 140 * (3), but 3 is a variable, so I couldn't write out the result. I assumed that writing "print hotel_cost" would work since that's the funciton, but it's not working out.


#4

Rather than printing the function, call it and print the result


#5

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