Creating a counter

Simon Kennedy sffjunkie at gmail.com
Thu Oct 16 16:12:07 CEST 2014


On Thursday, 16 October 2014 15:05:47 UTC+1, Ian  wrote:
> I would have suggested a Counter if I thought it fit the OP's use
> case. If you're listing directory contents, you're not going to have
> any repeated strings, so all the counts will be 1, and your Counter
> might as well be a list, which is what you got from calling
> os.listdir() in the first place. So I was more inclined to think that
> the OP was only trying to count one thing.

I read the OP's question as he was looking for the string in the contents of each file in the directory not in the file names themselves but as you say...

> In any case, the question turned out to actually be about printing,
> not counting.



More information about the Python-list mailing list