Brief
Visit every receipt, count distinct IDs, and calculate a total without treating copies as new events.
Voss points to four rows and claims “four departures.” Imani gives you authorized copies: R31 quantity 1, R31-copy quantity 1 with the same original ID, R32 quantity 2, and R33 quantity 3. Every row says “received,” not “released.” The story's meeting is near; take the time you need. Mara asks for a row-by-row report.
Your mission
- Give the human positions from
enumerate(receipts, start=1)and the Python list indices. - Describe how
seen, the count, and total change at each row. - Report distinct IDs and total received quantities, flagging the copy.
- Explain why this does not prove four departures and what to do if two R31 rows disagree on quantity.
How to check your work
- You give positions 1–4 and indices 0–3 separately.
- You do not add the R31 copy to count or total, but flag it.
- You get 3 distinct IDs and 1 + 2 + 3 = 6 parts recorded as received.
- You separate received from released and request review of conflicting copies.
Course example
receipts = [{'id': 'R21', 'quantity': 2},
{'id': 'R21', 'quantity': 2},
{'id': 'R22', 'quantity': 1}]
seen = set()
duplicates = []
count = 0
total = 0
for position, receipt in enumerate(receipts, start=1):
if receipt['id'] not in seen:
seen.add(receipt['id'])
count = count + 1
total = total + receipt['quantity']
else:
duplicates.append(receipt)
print(count)
print(total)
print(len(duplicates))