From the course: Python Code Challenges for Data Analysis
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Solution: Released by year - Python Tutorial
From the course: Python Code Challenges for Data Analysis
Solution: Released by year
- [Instructor] Let's take a look at the test code section first. So these two test cases correspond to these two sections that we have over here. Now, let me make sure that I understand what my data looks like. I'm just going to comment this out. And so let me work my way through the movies list for movie and movies. I just want to go ahead and print the movie. I just want to go ahead and print the first movie because I don't have a whole lot of space on my console output. And you can see that I've got the first movie, which is "The Shawshank Redemption." Now, anytime I want to count objects in Python, I almost always will use counter from the collections module. So let's go ahead and do that. So from collections import counter, and let me just go ahead and return the counter. And what's nice about this is, I can actually work my way through the movie and movies and count the object that I want. And in this case, what I want to count is the release date by year. And so it's this field…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.