I created a program in python to check if a given number is square or can be written as sum of two squares, but it doesn't work.please help me.
def sum(num):
def m(a):
b=a
for item in range(a):
b=b-1
if a==b*b:
return(a)
c=num
for item in range(1,num):
c-=1
if m(c)==c and m(d)==d:
print(num)