0
can anyone explain me the answer of below code
def func(x): res = 0 for i in range(x): res += i return res print(func(4))
2 Answers
+ 4
for i in range(4)
i takes the values from 0 to 3.
0+1+2+3=6 so res will return value as 6
+ 3
0 +1+2+3=6
def func(x): res = 0 for i in range(x): res += i return res print(func(4))