Advertisement
rfmonk

collection_counter_update.py

Jan 9th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. import collections
  5.  
  6. c = collections.Counter()
  7. print 'Initial :', c
  8.  
  9. c.update('abcdaab')
  10. print 'Sequence:', c
  11.  
  12. c.update({'a': 1, 'd': 5})
  13. print 'Dict  :', c
  14.  
  15. # the count values are increased rather than replaced
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement