Code result doubt

Why is it giving incorrect result:
import math
def squarePair(number):
pairs = []
limit = int(math.sqrt(number))
for i in range(limit+1):
for j in range(i,limit+1):
if ((i2) + (j2) == number):
pairs.append((i,j))
break
for k in pairs:
print (k)

T = int(input())
for i in range(T):
squarePair(int(input()))

import math
def squarePair(number):
pairs = []
limit = int(math.sqrt(number))
for i in range(limit+1):
for j in range(i,limit+1):
if ((i2) + (j2) == number):
pairs.append((i,j))
break
for k in pairs:
print (k)

T = int(input())
for i in range(T):
squarePair(int(input()))

Hey @rishverma, sorry for the late reply. The error that I found in your code is in line 7 :

if ((i2) + (j2) == number):

Here i2 and j2 are incorrect. We need to raise i to the power of 2 and raise j to the power of 2.

Hope this helps.
All the best :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.