I has a small question, Let me share a small snippet of code
num = [1, 2, 3, 4]
for i in num:
print(i)
num[2] = 5
here the output is
1
2
5
4
the iterator's value got updated to 5 instead of 3 in the 3rd iteration, now if I do this
num = [1, 2, 3, 4]
for i in num:
print(i)
num = [5 if j == 3 else j for j in num]
the output is
1
2
3
4
the iterator stayed the same this the 3rd iteration Does anyone know the reason for this behavior? (I observed this in Python 3.8 or 2.7)