Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. for root, dirs, files in os.walk(path):
  2. print(root) # print text to keep track the process
  3. count += sum(1 for f in files if f.endswith('txt'))
  4.  
  5. # This second line matches your existing behavior, but might not be intended
  6. # Remove it if directories ending in .txt should not be included in the count
  7. count += sum(1 for d in files if d.endswith('txt'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement