Increase value in hash table

Vito De Tullio vito.detullio at gmail.com
Thu Jan 24 19:30:17 CET 2013


moonhkt wrote:

> Data file
> V1
> V2
> V3
> V4
> V4
> V3
> 
> How to using count number of data ?
> 
> Output
> V1 = 1
> V2 = 1
> V3 =2
> V4 = 2

import collections

with open(data_file) as f:
        print(collections.Counter(f.readlines()))


it's a start

-- 
ZeD




More information about the Python-list mailing list