I am pretty new to Python, and I'm trying to check whether or not an integer submitted by the user is a perfect square, and this is what I came up with:
import math
number=int(input("Insert number here: "))
root= math.sqrt(number)
if isinstance(root, int):
print("This number is a perfect square!")
else:
print("This number is not a perfect square!")
Now, I understand that the problem is that, if i were to input 9
, the program would store root as 3.0
, which would make it a floating point. But how can I fix this?