0

Why is this the output?

i = 0 x = 0 while i < 4: x+=i i+=1 print(x) why is the output 6 for this code?

9th Jan 2022, 1:12 AM
Johan Ahmed
Johan Ahmed - avatar
1 Answer
+ 4
Cause 0 + 1 + 2 + 3 is 6 Print both variables in the for loop to see why for yourself
9th Jan 2022, 1:16 AM
Slick
Slick - avatar