jeudi 14 mai 2015

Python Counter dont count

import urllib2
f=urllib2.urlopen("http://ift.tt/1RIpbSA")
list = range(1,50)
counter={}

for lines in f:
    tab_lines=lines.split(" ")
    formated_tab=tab_lines[-1].strip().split(',')
    #print formated_tab
    for i in formated_tab:
        if i in list:
            counter[i]+=1
print counter.items()

Counter doesn't work and I don't know why :( This is a list of lottery numbers. I would like count how many times drawn each number.

Aucun commentaire:

Enregistrer un commentaire