When I print I get:
Counter({'pit': 6, 'mike': 4, 'andy': 3, 'jose': 2})
<class 'collections.Counter'>
How can I convert the result into:
pit = 6
mike = 4
andy = 3
jose = 2
Or a text file that shows:
pit 6
mike 4
andy 3
jose 2
When I print I get:
Counter({'pit': 6, 'mike': 4, 'andy': 3, 'jose': 2})
<class 'collections.Counter'>
How can I convert the result into:
pit = 6
mike = 4
andy = 3
jose = 2
Or a text file that shows:
pit 6
mike 4
andy 3
jose 2
If you want you can extend dict
object and override the __str__()
function to something like this :
def __str__(self):
out = ''
for k, v in self.iteritems():
out += "%s\t%s" % (k, v)
return out
This should output what you want each time, the object is represented or printed.