I decided to make a program that would square a number just for fun. Using an online compiler, I entered my code and from what I saw there were no errors; it wouldn\'t run it wo
Do make sure you also call your function:
def square():
# your function body here
square()
But in your function, you are ignoring the result of your calculation here:
number*number
Assign that result to something:
answer = number * number
print "Your answer is..."
print answer
You don't have a number, however. raw_input()
returns a string, so you want to convert that to a number first:
number = int(number)
This assumes that the user actually entered something that can be converted to an integer; digits only, plus perhaps some whitespace and a +
or -
at the start. If you wanted to handle user errors gracefully here, take a look at Asking the user for input until they give a valid response for more advanced options.