I have a problem


im stuck at 3.getting there
aparently, los angeles isnt returning 275

def hotel_cost(nights):
    return 140 * nights
def plane_ride_cost(city):
    if city is 'Charlotte':
        return 183
    if city is 'Tampa':
        return 220
    if city is 'Pittsburgh':
        return 222
    if city is "Los Angeles":
        return 475


Hi @frightningfedoras ,

For "Los Angeles", you have ...

return 475


its supposed to be 475. i dont know why i put 275. sorry


For this exercise, use == instead of is in your conditional statements.

For example, instead of ...

if city is 'Charlotte':

... use ...

if city == 'Charlotte':


i see. Thanks! the minimum reply length is 20 soo... thats what this sentence is for!


Hello again @frightningfedoras ,

The == operator checks whether two objects are considered to be equivalent.

The is operator checks whether they are actually stored as the same object.

If what we consider to be two strings consist of the exact same sequence of characters, they are equivalent, and the == operator can verify that. The two equivalent strings might also be the same object, but they might not be. See the following experiment ...

# Experiment: equivalence and identity of strings
a = "Los" + " " + "Angeles"
b = "Los Angeles"
# Show that strings a and b look alike
print a
print b
# Are they equivalent? (yes)
print a == b
# Are they the same object? (might not be)
print a is b

Output ...

Los Angeles
Los Angeles

In the above, the strings were equivalent, but the Python interpreter stored them as two separate objects. So, in general, when you want to check whether two strings consist of the same sequence of characters, use the == operator.


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