"""
Exercise 2: fix the mutable default argument bug

record_event below is supposed to append an event name to a per-call
log and return that log, WITHOUT leaking state between unrelated calls
that don't pass their own log in.

As written it has the classic mutable-default bug. Fix it.
"""

def record_event(event, log=[]):   # BUGGY — fix the signature/body
    log.append(event)
    return log


# --- self-check: do not modify below this line ---
first_call = record_event("login")
second_call = record_event("logout")

ok1 = first_call == ["login"]           # must NOT contain "logout"
ok2 = second_call == ["logout"]         # must NOT contain "login"

my_log = []
record_event("a", my_log)
record_event("b", my_log)
ok3 = my_log == ["a", "b"]               # explicit log still works normally

print(f"first_call={first_call!r} -> {'PASS' if ok1 else 'FAIL'}")
print(f"second_call={second_call!r} -> {'PASS' if ok2 else 'FAIL'}")
print(f"my_log={my_log!r} -> {'PASS' if ok3 else 'FAIL'}")
print("ALL PASS" if (ok1 and ok2 and ok3) else "SOME FAILED")
