I'm doing an exercise on codewars and I'm supposed to find out if a number is a perfect square. I got the code done for the most part and it works most of the time, but when returning False, i get the wrong answer.
def is_square(n):
if n<0:
return False
if n == 0:
return True
if n>1:
for i in range(0,n):
if i*i==n:
return True
else:
return False
If I remove the last else statement, 4 and 25 return true, but when I add in the last else statement, it says 4 and 25 are false. How would I go about fixing it so it returns false if 27 is entered while maintaining 25 to be true?