0
I am not able to understand how the final result is 6
def func(x): res = 0 for i in range(x): res += i return res print(func(4))
1 ответ
+ 1
range(4) = 0 , 1 , 2 , 3
for i in range(x): res += i
So it mean res is summary of range(4) = sum(0, 1, 2, 3) = 6