0
output
I don't understand, the output of def func(x): res = 0 for i in range(x): res += i return res print(func(4)) is 6, but shouldn't it be 10? because 1+2+3+4=10? I am confused
1 ответ
+ 2
for i in range(x) -> excluding x
i starts at 0 and ends at 3.
You can see it when you add a print statement inside the loop.