I'm trying to iterate over files in a directory using the following command in python 3.6:
for filename in os.listdir(my_dir)
My files are numbered incrementally, like out1, out2, ...,out10, out11, ...
. Unfortunately, iteration over the files using the above command results in out1, out10, out11
instead of out1, out2, out3, ...
. It might be correct from file system point of view, but semantically wrong.
How can we get the right output?