Your question is Validate Test Lifecycle Sequence. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a list of lifecycle event strings events, determine whether the sequence is valid. Each event is one of "PLAN", "EXECUTE", "DEFECT", "RETEST", or "CLOSE". A valid sequence must follow these rules: PLAN must occur before any other event, EXECUTE can occur only after PLAN, every DEFECT must be matched by a later RETEST, and CLOSE can appear only once at the end after all defects have been retested. Return True if the sequence is valid, otherwise return False.
def validate_lifecycle(events):