Adding numbers to filenames

I am new to any kind of scripting. I wrote a python script to add numbers to the end of filenames, and pad zeros to the numbers. It will work, but it does not keep the numbers in sequential order. This is the script. Any ideas would be appreciated.

import os

def main():
path=“C:/Users/Test/”
for count, filename in enumerate(os.listdir(path)):
dest = filename + str(count).zfill(3)
source = path + filename
dest = path + dest

  # rename() function will 
  # rename all the files 
os.rename(source, dest) 

Driver Code

if __name__ == '__main__': 

Calling main() function

main() 

Here are the original file names.
gfs.t00z.pgrb2.0p251f
gfs.t00z.pgrb2.0p25!f
gfs.t00z.pgrb2.0p25&f
gfs.t00z.pgrb2.0p25.f
gfs.t00z.pgrb2.0p25_f
gfs.t00z.pgrb2.0p25+f
gfs.t00z.pgrb2.0p25cf
gfs.t00z.pgrb2.0p25-f
gfs.t00z.pgrb2.0p25ff
gfs.t00z.pgrb2.0p25if
gfs.t00z.pgrb2.0p25lf

Here is what I get after I run the script.
gfs.t00z.pgrb2.0p251f001
gfs.t00z.pgrb2.0p25!f002
gfs.t00z.pgrb2.0p25&f005
gfs.t00z.pgrb2.0p25.f011
gfs.t00z.pgrb2.0p25_f003
gfs.t00z.pgrb2.0p25+f007
gfs.t00z.pgrb2.0p25cf004
gfs.t00z.pgrb2.0p25-f008
gfs.t00z.pgrb2.0p25ff009
gfs.t00z.pgrb2.0p25if010
gfs.t00z.pgrb2.0p25lf006

You have numbers in sequential order from 1 to 11, but you should check the documentation for os.listdir() to see in what order you are getting the filenames.

Thanks Simon. I will check out os.listdir() documentation.