Real data usually arrives as a list of records. Here you'll process a list of dictionaries, summarize each one with a function, and print a formatted report — combining dictionaries, loops, functions, and f-strings.
You're given a products inventory where each item is a dictionary with a name, price, and qty.
Your tasks
Given this starting value:
products — a list of three product dictionaries (see the starter code)
1. Write a function line_value(item) that returns price * qty for one product dictionary
2. Loop over products. For each product, print "<name>: $<value>" using line_value(), and add each value to a running total
3. After the loop, print "Total: $<total>"
Expected output
Keyboard: $120
Mouse: $200
Monitor: $300
Total: $620
Constraints
- Define and use the
line_value() function — do not hard-code the per-line values
- Use a
for loop over products
- Access dictionary values by key (e.g.
item["price"])
- Use f-strings for every printed line