+ 1
Code
What is the output of this code? def func(x): res = 0 for i in range(x): res += i return res print(func(4)) The answer is 6 ??
1 Answer
+ 6
range(4) returns [0, 1, 2, 3]
0+1+2+3 = 6
What is the output of this code? def func(x): res = 0 for i in range(x): res += i return res print(func(4)) The answer is 6 ??