from collections import defaultdict
d = {}
with open("sample.log") as samp:
for line in samp:
if line.split():
parts = line.split()
# 0 because if it's not found, the count should be 0
d[parts[2]] = d.get(parts[2], 0) + 1
print(d)
dd = defaultdict(int)
for line in samp:
parts = line.strip().split()
if line.split():
dd[parts[2]] += 1
print(dd)
the link for the l: https://drive.google.com/file/d/1o1ZSvJDA7n6diVNeJztQMMecBUgQUQu9/view?usp=sharing