Practice Question: For Loop
What is the output of the following code snippet?
for x in range(3):
print(x, end='')
x = 3Answer
The output is:
012Reassigning x inside the loop does not affect the iteration of the for-loop. This is because for x in range(3) gets each new value by calling next() on the range iterator, so changes to x inside the loop are ignored.