raw_input
returns a string, so you cannot use it for any calculations. If you want to have an integer instead, you can use the int
function to convert the value. You can do that either within your prompt
function, or later in the calling function (although it would make more sense to have a function that asks the user for a number return one):
def prompt ():
x = raw_input("Type a number: ")
return int(x)
Note, that int()
may raise a ValueError
for any user entered value that is not a valid integer. In that case, you should catch the exception and prompt the user again to correct the input. See this question on how that would work.