From the course: Python Data Structures: Dictionaries
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution - Python Tutorial
From the course: Python Data Structures: Dictionaries
Solution
(upbeat music) - [Instructor] Welcome back to the chapter two, case study problem solution. Did you have fun trying to find the answer? Let's try and go through this together. So a problem statement was, that we found when we read the Excel spreadsheet file, that the subdivision ID was not unique. That is, there were multiple orders from the same subdivision, making the subdivision ID occur multiple times in the Excel spreadsheet. Now, we also understood that the subdivision ID was the key for our dictionary. And we know that in Python dictionaries, keys have to be unique. So how do we write a program that solves this problem? That was our challenge. The solution that I recommend is, the number of trees from each subdivision should be computed and stored in a counter, which then gets copied to a corresponding value in the dictionary. Then you print the contents of the dictionary to see if the algorithm was indeed…
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.