Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for root, dirs, files in os.walk(path):
- print(root) # print text to keep track the process
- count += sum(1 for f in files if f.endswith('txt'))
- # This second line matches your existing behavior, but might not be intended
- # Remove it if directories ending in .txt should not be included in the count
- count += sum(1 for d in files if d.endswith('txt'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement