for root, subdirs, files in os.walk(dir): 
    for i in range(0, files.index(files[-1]) + 1):
files.index(files[-1]) here is the end index of item in files, and I got it. 
But I want to know is there a simple way to get it? I know if I got the end item, say, like "d", after typing in files.index("d"), I would have gotten the index.
 
     
    