Well i can simply put a variable in place of 'n' in square(n) but I tried to allow user to enter a number, but this code is not working and showing this error
Traceback (most recent call last):
File "python", line 10, in <module>
File "python", line 3, in square
TypeError: unsupported operand type(s) for ** or pow(): 'unicode' and 'int'
Code
Traceback (most recent call last):
File "python", line 10, in <module>
File "python", line 3, in square
TypeError: unsupported operand type(s) for ** or pow(): 'unicode' and 'int'
Code
def square(n): squared = n ** 2 print "%d squared is %d." % (n, squared) return squared n=raw_input("enter a no") square(n)