I am trying to loop through the files in a folder with python. I have found different ways to do that such as using os package or glob. But for some reason, they don't maintain the order the files appear in the folder. For example, my folder has img_10
, img_20
, img_30
... But when i loop through them, my code reads the files like: img_30
, img_10
, img_50
... and so on.
I would like my program to read the files as they appear in the folder, maintaining the sequence they are in.