← Course Home
Module 13 · Tier 4

Orphaned/Suspended Account Finder

A real access-review finding: an account that's suspended, or belongs to zero groups, with no clear owner. Ten labs on Module 6 — loops, accumulators, filtering, nested loops — over the real 12-person fixture.

Lab 1

Loop and Print

Loop all of USERS, printing "FIRSTNAME -- STATUS" for each — 12 lines.

→ 12 lines, e.g. Julio -- ACTIVE ... Pat -- DEPROVISIONED
Lab 2

Branch Inside the Loop

Loop all USERS. For each, print "FIRSTNAME: ACTIVE" if their status is ACTIVE, otherwise "FIRSTNAME: not active".

→ 12 lines, 8 say ACTIVE, 4 say not active
Lab 3

Filter With an Accumulator

Loop all USERS, building a list of first names of every SUSPENDED user (accumulator pattern: empty list, append inside an if). Print the list.

['Bina', 'Rosa']
Lab 4

Same Filter, As a Comprehension

Rewrite Lab 3 as a single list comprehension.

['Bina', 'Rosa'] — identical result
Lab 5

Count With an Accumulator

Loop all USERS, counting how many are DEPROVISIONED using a counter variable. Print the count.

2
Lab 6

Nested Loop: Every Membership

Loop the first two users (USERS[:2]), and for each, loop their groups, printing "FIRSTNAME belongs to GROUPNAME" for every membership.

→ 5 lines (Julio has 2 groups, Amy has 3)
Lab 7

Find the Zero-Group Accounts

Loop all USERS, building a list of first names of every user with len(groups) == 0. Print the list — these are your orphan candidates.

['Dana', 'Tri', 'Pat']
Lab 8

Combine the Two Conditions

Loop all USERS, building a list of first names of anyone who's SUSPENDED or has zero groups (single if with or). Print the list.

['Bina', 'Dana', 'Tri', 'Rosa', 'Pat']
Lab 9

Guard the Loop

Loop all USERS, printing "FIRSTNAME: DEPARTMENT" for each, guarding the missing department with .get(..., "Unknown") — confirm no crash on Layla.

→ 12 lines, Layla's line reads Layla: Unknown
Lab 10 · Capstone

The Full Flag Report

Loop all USERS, flagging anyone SUSPENDED or with zero groups (Lab 8's condition), guarding department (Lab 9), building formatted lines "FIRST LAST -- STATUS -- DEPARTMENT". Print "Flagged accounts: N" first, then every flagged line.


Flagged accounts: 5
Bina Patel -- SUSPENDED -- Sales
Dana Morris -- ACTIVE -- IT
Tri Nguyen -- DEPROVISIONED -- Sales
Rosa Gomez -- SUSPENDED -- IT
Pat Hogan -- DEPROVISIONED -- Sales
Now go practice

Open problems/tier04_orphan_finder.py and do all 10 problems locally. Uses fixture.py -- type it in first from DAY1_01_FIXTURE.md if it's not already in this folder. Run python check.py in problems/ to grade everything.

Tier 4 complete

On to Tier 5

looping and printing → branching inside a loop → filter with an accumulator → the same filter as a comprehension → counting with an accumulator → nested loops over memberships → finding zero-group accounts → combining two conditions → guarding inside a loop → the full flag report.

← Back to Module 13