0
why the answer is 8?
for i in range (5): i += i print (i)
2 Answers
+ 3
'i' is a temporary variable, each iteration replaced by the next value from the itearable range(5) so last value 4 is replaced by previous value and it's i+=i cause it's value 4+4=8 , it is retained after loop and it printed.
Try to test printing inside loop then you can see each values...
Hope it helps...
+ 1
Indent the third line (the print (i) statement) and see how the output works:
for i in range (5):
i += i
print (i)