HEEELLLLLP! I command you to!


Whats wrong?
def hotel_cost(nights):

    return hotel_cost(140 *nights)

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

Oops, try again.
Did you create a function called plane_ride_cost?
File "python", line 9
if city == "Charlotte":
IndentationError: expected an indented block


Python depends upon indentation to demarcate the boundaries of a function (scope) as well as boundaries of control flow structures (block scope).

def my_function(param):
    if condition == "something":
        return a_value
    elif condition2 == "something else":
        return a_different_value

Notice there are two levels of indentation. The first is function scope, the second is block scope. Note too that Python starts a block with a colon.


so you are saying not only my indentation is wrong but my spacing aswell?


Spacing is not a concern as much as indentation. We are allowed white space in our code, so long as the indents are correct. My example is only meant as that, an eg.


== discussions / opinions ==


google search
== the Book ==
[your question] site:python.org

== discussions / opinions ==
python [your question] site:stackoverflow.com