hey

i was doing this simple python exercise

’ Exercise Question 6: Write a recursive function to calculate the sum of numbers from 0 to 10

**Expected Output** :

55’

it was pretty easy and my answer was

'def sum(n):

k=0

for i in range(n+1):

k+=i

else:return k

print(sum(10))’

it worked properly

but when i looked at the solution i didnt get how does it work exactly

the solution was

```
def calculateSum(num):
if num:
return num + calculateSum(num-1)
else:
return 0
res = calculateSum(10)
print(res)
```

please explain it to me

thanks