[Solved] Summarizing a python list of dicts

Here’s something you can try. It uses a collections.defaultdict or collections.Counter to count High, Med and Low for each product, then merges the results at the end. from collections import defaultdict, Counter product_issues = [ {“product”: “battery”, “High”: 0, “Med”: 1, “Low”: 0}, {“product”: “battery”, “High”: 1, “Med”: 0, “Low”: 0}, {“product”: “battery”, “High”: 1, … Read more

[Solved] What is wrong with my “summarize” command?

Python is not Java. You don’t need setter functions for every property. Use the __init__ method to initialize your object: class Textbook: def __init__(self, title, author, publisher, year, course, semester): self.title = title self.author = author self.publisher = publisher self.year = year self.course = course self.semester = semester def summarize(self): s=”{:40s} {:15s} {:15s} {:4d} {:8s} … Read more