+ 2
Can someome please explain why the result here is 6 ?
def func(x): res = 0 for i in range(x): res += i return res print(func(4)) and why if I change the number 4 with 5 I will get 10. thank you
2 Answers
+ 2
Because i is being incremented each loop so. 1 + 2 + 3 + 4 + 5 ...
+ 2
thank you very much, now I understand