Taking a vaction/ getting there


#1


#2

Hi there. There are some errors in your code.

Take a look at the instructions (step #1):

Below your existing code, define a function called plane_ride_cost that takes a string, city, as input.

Here in your code on row 3:

plane_ride_cost = (city)

That's not right. They asked you to define a function not create a variable called plane_ride_cost.
Here's how defining a function should look:

def function(input):

Now, in your if/elif statements, in the instructions (step #2) they ask:

The function should return a different price depending on the location, similar to the code example above. Below are the valid destinations and their corresponding round-trip prices.

"Charlotte": 183
"Tampa": 220
"Pittsburgh": 222
"Los Angeles": 475

Here, they ask for you to return the price that belongs to the location.

Your code (showing one of your statements):

if "Charlotte": 183
    return

In these statements, you need to check if city is equal to your destinations (e.g. "Charlotte"), then return the cost (the prices given in the instructions above) after your statements below them.
Also, don't forget to indent your code in the function and in your if/elif statements. :slight_smile:


#3

In addition to that, first two lines are obsolete, right?


#4

Do you mean the first two quotes? The second quote is some of Azere's code, while the quote above is from the instructions.


#5

Yeah I meant from Azere's code, first two quotes are not necessary here.
Sorry for the confusion.


#6

I think the first two lines are not necessary here:
def hotel_cost(nights):
return 140 * nights


#7

I'm just explaining the instructions.


#8

Exactly! And I appreciate that.
I was just asking for your thought on that. Was I right or wrong?


#9

I meant was it correct or not?


#10

Do you mean your thought on removing this?:

They are necessary. You will be needing to call this function later on in the Taking a Vacation courses in Python.


#11

def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(city):
if city =="Charlotte":
return 183
elif city == "Tempa":
return 220
elif city == "Pittsburgh":
return 222
elif city == " Losangeles":
return 475
else:
return "service not available"

print plane_ride_cost("Tempa")
output
220
None
And I got this message:
Oops, try again. It looks like plane_ride_cost does not return 220 when the city is Tampa.

What do you think is wrong with my code?

Note: proper indentations were made.


#12

You misspelled Tampa.


#13

really guys your acting my age and I'm 14 you guys are have a strong disagreement I like that your helping me and all but I have already got past this part I'm sorry if this cause any trouble. it doesn't really matter he or she made a mistake and intermediategamer corrected it shouldn't have went any further than what it got to


#14

really guys your acting my age and I'm 14 you guys are have a strong disagreement I like that your helping me and all but I have already got past this part I'm sorry if this cause any trouble. it doesn't really matter he or she made a mistake and intermediategamer corrected it shouldn't have went any further than what it got to


#15

I thought we were just discussing the topic. I am a new bee in coding just like you and asking for suggestions from the help desk, because I was not sure!
I really did not mean anything!


#16

Sorry, If that cause any misunderstanding.


#17

My apologies for the argument. I didn't mean for your topic to turn out this way. I would of rather users create a new topic instead of commenting on someone else's (like yours). :sweat:
I'm not a moderator, so can't split new topics when someone asks for help, and calling a moderator to do this would of been a bad decision, so I left it alone. I'm not an adult and I know better than to 'argue' with someone. I was just simply answering their question and letting it be. :slight_smile:
Again, I'm sorry for the argument, and no - you caused no trouble at all. This was your topic, not someone else's to hijack. New users are still trying to navigate themselves around the forums, and seeing something like this is understandable. :slight_smile:


#18

yeah now everybody good :sweat_smile::grin:


#19

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