In Python, "whitespace" makes a difference. The level of indentation is important, and your code will error if you don't indent appropriately. You can read more about Python Whitespace here, but I'll give you a summary.
In Python, when you run your program, it gets passed through what is called an Interpreter, which converts it from the code you can understand into the code that your computer can understand. For Python, this interpreter needs your code to be indented, so it knows how to convert it. Every time you do an if
, else
, for
function
or class
(among others), you need to increase your indentation.
def getinput(cost):
cost = raw_input('Enter a number')
The above should work, while the following will not:
def getinput(cost):
cost = raw_input('Enter a number')
Notice how the first example isn't indented. Good luck with learning Python!