Can someone explain why this code only prints 6? :)
result = 0
for i in range(x):
result = result + i
In your code, you were simply adding up the integers from [0,4) (i.e. 0+1+2+3=6), that's why it only prints 6 when you call
If you call
print(func(1)) the range would be [0,1) meaning it's just 0, so that statement will only print 0.