I cannot find out whats happening here!


#1


Oops, try again. Did you create a function called plane_ride_cost?

script.py

def hotel_cost(nights):
return 140 * nights
def plane_ride_cost('city'):
if plane_ride_cost("Charlotte"):
return (183)
else:
if plane_ride_cost("Tampa"):
return (220)
else:
if plane_ride_cost("Pittsburgh"):
return (222)
else:
if plane_ride_cost("Los Angeles"):
return (475)
File "python", line 3
def plane_ride_cost('city'):
^
IndentationError: unindent does not match any outer indentation level


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


#2

The elif keyword is designed to prevent this sort of code. else: if: requires an indent on the if.

Consider,

if ___:

elif ___:

elif ___:

else:

In this case, there is no need for else: so that can left out.


#3

A post was split to a new topic: Why won't my code work?


#4

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