+ 1

What is the output of this code?

for i in range (5): i=i+i print(i) Answer is 8.how??

28th Jun 2018, 12:51 PM
Supriya Gangapatnam
Supriya Gangapatnam - avatar
2 Answers
+ 1
Range would generate a list from 0 to 4 with which the for loop would go through. Last iteration would mean that i = 4 and that i = 4 + 4, which would output 8
28th Jun 2018, 12:56 PM
apex137
apex137 - avatar
+ 1
thank you so much
28th Jun 2018, 12:57 PM
Supriya Gangapatnam
Supriya Gangapatnam - avatar