LLD - Design — Splitwise (Expense Sharing)
You have this code snippet to add a transaction record:
What is the output when running this code?
def add_transaction(history, transaction):
if transaction['id'] not in [t['id'] for t in history]:
history.append(transaction)
else:
print("Duplicate transaction")
history = [{"id": "t1"}]
add_transaction(history, {"id": "t1"})What is the output when running this code?
