Well I’m quite new to python and I’m struggling with this at the moment. I need to sum up all the answers(returns) from this for loop but I don’t really know how to do this.
a = int(input('Enter a number plz '))
for i in range(1, a+1):
def func(root):
print('Number', i, 'in square root is', root)
func(i*i)
>Solution :
The next code should solve a problem:
a = int(input('Enter a number plz '))
s = 0
for i in range(1, a+1):
def func(root):
print('Number', i, 'in square root is', root)
return root
s += func(i*i)
print("The sum is " + str(s))