I was trying to run this script in Python and I found something really strange:
test = ['file.txt', 'file1.mkv', 'file2.mkv']
for test in test:
print(test)
print(test)
once I run this script I was expecting an output like this:
file.txt
file1.mkv
file2.mkv
['file.txt', 'file1.mkv', 'file2.mkv']
Instead what I get is this:
file.txt
file1.mkv
file2.mkv
file2.mkv
I can't understand why the last line of output is "file2.mkv".
In the script I said to print every value in test
and then print test
. I never wrote to change the variable test
so there is no reason why the output is not the initial variable test
that I defined at the beginning.
I know I am probably wrong, but I would like to understand why.