I have a task to count symbols from multiple text files. I am near to finish but facing an issue. Below is my n I want to sum the commaCount value. I put command total = sum(commacount) but it shows error
total = sum(commaCount)
TypeError: 'int' object is not iterable
Here's my code:
import glob
def stats():
commaCount = 0
path = 'D:/Stiudies/Data/female/*.txt'
inf = glob.glob(path)
for name in inf:
with open(name, 'r', encoding="utf8") as input_file:
for line in input_file:
for char in line:
if char == ',':
commaCount += 1
total = sum(commaCount)
print(commaCount)
stats()