[Solved] I have a list of file names and I need to be able to count how many of the same file gets repeated for each file name [closed]


If you already have a list of filenames use collections.Counter:

from collections import Counter
files = ["foo.txt","foo.txt","foobar.c"]

c = Counter(files)
print (c)
Counter({'foo.txt': 2, 'foobar.c': 1})

The keys will be your files and the values will be how many times the file appears in your list:

solved I have a list of file names and I need to be able to count how many of the same file gets repeated for each file name [closed]