- [Instructor] As I mentioned earlier,…one of the common uses of dictionaries is to keep track…of the count of individual items.…And the collections modules supplies a counter class which…is a dictionary subclass for counting hashable objects.…Now you might be saying wait a minute,…we saw how to do this earlier with the default dict class.…And that's true, but counters have some nice additional…features for working with numbers of items.…So let's start with an example where we have two lists.…I'm gonna open up my counter underscore start example file…in my collections folder.…
And you can see I have two lists of student names…for two different classes.…So counters can be initialized in a variety of ways.…And in this case I'll create two of them,…using the name lists.…So I'll have C one equals counter for class one,…and C two I'll make a counter for class two.…And by the way you can see up here on line three…I've already imported the counter class…from the collections module.…
So let's try a few operations.…Now since a counter is a dictionary,…
- Truth value testing
- Template strings
- Advanced Python functions
- Advanced collections
- Advanced classes and objects
- Python comprehensions: list, dictionary, and set
Skill Level Advanced
1. Python Language Features
2. Built-In Functions
3. Advanced Python Functions
4. Advanced Collections
5. Advanced Classes and Objects
6. Using Logging
7. Python Comprehensions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.