Extract lines from file, add to new files

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jan 12 18:34:07 EST 2024


On 13/01/24 12:11 am, Left Right wrote:
>      x = [...]
>      for x[i] in x: print(i)

I suspect you've misremembered something, because this doesn't
do anything surprising for me:

 >>> x = [1, 2, 3]
 >>> for x[i] in x: print(i)
...
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
NameError: name 'i' is not defined

There's no destructuring going on here, just assignment to a
sequence item.

-- 
Greg


More information about the Python-list mailing list