Lendbuzz's subscription billing service stores plan changes as effective-month events. Implement a function that returns the active monthly price for a subscription during a requested month.
Each event either activates or changes the subscription price, or cancels the subscription. Events may be provided in any order. If multiple events have the same effective month, the event appearing later in the input takes precedence. An event affects its effective month and every later month until another event replaces it.
Implement active_monthly_price(events, target_month).
events is a list of dictionaries with integer effective_month, nonnegative integer monthly_price in cents, and string status, which is either "active" or "cancelled".target_month is an integer in YYYYMM format.0 if no event has taken effect yet or the latest applicable event is cancelled.def active_monthly_price(events, target_month):