Step 1: Identify correct attribute for multiple users
A list is suitable to hold multiple User objects, so self.users = [] is correct.
Step 2: Check other options for correctness
class Group:
def __init__(self):
self.user = {} uses a dict named user which is not typical for holding users; class Group:
def __init__(self):
self.expenses = [] uses expenses which belongs to Expense class; class Group:
def __init__(self):
self.members = None sets members to None which is not a collection.
Final Answer:
class Group:
def __init__(self):
self.users = [] -> Option A
Quick Check:
Group holds list of users = self.users = [] [OK]
Quick Trick:Group holds list of users with self.users = [] [OK]
Common Mistakes:
MISTAKES
Using dict instead of list for users
Confusing expenses with users
Initializing members as None instead of a list
Master "Design — Splitwise (Expense Sharing)" in LLD
9 interactive learning modes - each teaches the same concept differently