Python: Getting There not working help!


#1

It says the following:

Did you create a function called plane_ride_cost?

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
  
  else:
    return 475

#2

That looks suspicious. Any random flight will cost 475?

Where is Los Angeles in the mix?

Should there be a value in the else clause?

Should there even be an else clause? Without it the function will retun None which is valid and appropriate in this scenario.


Aside

One of the best habits to form is four space indents. Sure we will find editors or sandboxes that default to two spaces, but they don’t buck four so there is a happy marriage. CC courses will more than likely look for or expect four. That is why I bring it up.

Reading on the web it turns out four spaces is the norm in the higher income range. Urban myth? Fake news? Worth considering? Good habits are what earn higher incomes. That for me would be the bottom line.


#3

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