[Solved] Python script counting lines in multiple text files in one directory and producing simple report
Your names dict looks like that: { ‘file1.txt’: 30, ‘file2.txt’: 26, ‘file3.txt’: 19, ‘file4.txt’: 19 } So you’d just have to start from that and follow with: from collections import defaultdict lines = defaultdict(int) for val in names.values(): lines[val] += 1 for k, v in lines.items(): print(“Files with {} lines: {}”.format(k, v)) This will print … Read more