I want to learn Python and I took a test. I the test I came across this code and I needed to get it's output.
I put the correct answer which was 6, but I didn't understand the code, I just put it in an online python compiler!
Why does this code output a 6?
def func(x):
res = 0
for i in range(x):
res += i
return res
print(func(4))
xtype (string,int,char,float)