HEEELLLLLP! I command you to!


#1

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


#2

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
    else:
        pass

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.


#3

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


#4

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.


#5

@flyingdestruction,
== discussions / opinions ==
http://stackoverflow.com/questions/8853063/pep-8-why-no-spaces-around-in-keyword-argument-or-a-default-parameter-value
http://stackoverflow.com/questions/2034517/pythons-interpretation-of-tabs-and-spaces-to-indent
http://stackoverflow.com/questions/6388187/what-is-the-proper-way-to-format-a-multi-line-dict-in-python

Reference

google search
== the Book ==
[your question] site:python.org
http://www.python.org/dev/peps/pep-0008

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