0
Can someone explain to me this output?
result=0 n=5 for i in range(1,n+1): result+=i print(result) why the output is 15, if we calculate 1,6 is 1,2,3,4,5 so I am not sure how 15 is calculated ...
2 Respostas
+ 2
This won't output 15 ... It will be 5 because the loop will run 5 times and result+=1 (result will add 1 in each loop)
If u do result+=i, it will output 15
0
you are right it is i, but how dis you get 15?