15,958,539 members
1.00/5 (1 vote)
See more:
Length of int(b**0.5) is always coming to be 1, this is the problem.

If the no. Will be perfect it's root length will be small and if it is not a perfect square then it will be in decimal and it's root length will be big.

What I have tried:

Python
```Def square():
a=int(input("Enter the no."))

b=int(a**0.5)
If Len(b)==1 or Len(b)==2:
Print("the number is a perfect square")

Elif Len(b)>3:
Print("is not perfect square")

#Its not working.```
Posted
Updated 18-Aug-22 22:12pm
v3
Patrice T 18-Aug-22 14:02pm
How "Its not working.", give details
Richard Deeming 19-Aug-22 3:47am
"if it is not a perfect square then it will be in decimal"

So why are you casting the square root to an `int` then?

## Solution 1

Pretty much every line of code is incorrect. It looks as if you have been trying to write VB.NET statements with Python expressions. Python is a case sensitive language and all statements and builtin functions use lower case. You also do not need to check the length of `b`, but its value from the previous expression. You also do not need to check if it is greater than 3 (actually should be greater than 2) since if it is not 1 or 2 then it must be greater than 2. So go to The Python Tutorial — Python 3.10.6 documentation[^] and study the proper syntax of the language. Then think about what you need to do to correct your code.