a guest Jul 22nd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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'))
  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'))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand