I am trying out python list iteration code and got confused by the output of the below code snippet
>>> dir1 = ['f1', 'f2', 'f3']
>>> dir1
['f1', 'f2', 'f3']
>>> for i in dir1:
... print(i)
... dir1.remove(i)
...
f1
f3
version: 3.4
>>> import sys
>>> sys.version
'3.4.0 (default, Apr 11 2014, 13:05:11) \n[GCC 4.8.2]'
As per my understanding the output should be as below ( in any order):
f1
f2
f3
Can someone explain this behaviour?