This error has nothing to do with raw_input
. You may, however, want to read about indentation in Python. Many other languages use curly braces such as {
and }
to show the beginning and the end of a program, or keywords like begin
and end
. In Python, in contrast, you have to indent the code, like this:
def getinput(cost):
cost = raw_input('Enter a number ')
So if you do it without indentation, e.g.
def getinput(cost):
cost = raw_input('Enter a number ')
...Python would give you an error.