audit_log = [] already exists. Write a function record_event(event) that appends event to audit_log (an intentional side effect, making this function impure) and returns the new length of audit_log. This problem is about recognizing and correctly implementing an impure function, contrasted with pure functions elsewhere.record_event("login")
record_event("logout")1, 2
Each call mutates the shared audit_log list and returns its new size.
list.append() mutates in place, so you do not need the global keyword just to call it (global is only required to rebind the name itself).
Return len(audit_log) after appending.