Python报错can't convert complex to int

for i in range((x+1)2):
if i
0.5 == int(i**0.5) and (i-168)0.5 == int((i-168)0.5):
print(i-100)
这段代码、报错line 8, in
if i
0.5 == int(i
0.5) and (i-168)**0.5 == int((i-168)**0.5):
TypeError: can't convert complex to int
如果i-168改成i+168就没事,成功运行。这是为什么?

因为i很小时 你减去168是负数,负数无法开方


x=2
for i in range((x+1)*2):
    if i*0.5 == int(i**0.5) and (i-168)*0.5 == int((i-168)*0.5):
        print(i-100)

img