In the second line, I have used If condition to test if index is not 0 then print else do nothing. So it just print after 0.
And in the third final line we print the index i.e. the number followed by each.split(..) btw what is it ? ok lets get into detail. When we were iterating the list of files each file name is stored as a string inside the list and I know strings have a function called split that takes by whatever you want to split and it returns a list . So what I am doing is taking a list getting each item as string and splitting that string to a new list and then from the new list I am getting the filename, since it has an extension prefixed I am getting rid of it by again splitting that file name to a list and getting rid of the extension. So this is how I end up with just the name that has index number before it.
Now lets write the above index to a text file.
(I will create a file at the same location where the other files were located)
In the above for loop I have used str(index) to typecast integer to string variable so I can concatenate it to a string followed by space in double inverted commas and \n to insert a new line.
Thanks for reading, I will come up with something more useful in future whenever I get time to write.