I want to make a function in python that gets the square of digit values only and when invoked with a string it does not give an error and instead returns a message. This is what I have reached till now.
What I have tried:
def square(x):
    answer = x
    if answer == answer.int()  :
        print("the square of" ,x, "is", x*x)
    if answer == answer.str() :
        print("please enter a valid number to find its square")
but it gives me the error when invoked with a string such as "joe" as seen here:
Input In [114], in <cell line: 1>()
--->  1 square("joe")
Input In [113], in square(x)
  1 def square(x):
  3     answer = x
--->  4     if answer == answer.int()  :
  5         print("the square of" ,x, "is", x*x)
  7     if answer == answer.str() :
AttributeError: 'str' object has no attribute 'int'
 
     
     
     
     
    