Using looping as follows to list n files from a directory:
myfiles = glob.glob("*.xml")
files = len(myfiles)
count = 0
myfiles.sort()
files_to_process = 3
for filename in myfiles:
count += 1
print (time.strftime("%I:%M:%S"), count ,'of', files, '|', filename)
if count == files_to_process:
break
is there an alternative way to iterate only through n times other than using break?