Complete the code to declare the User class with an __init__ method.
class User: def __init__(self, name): self.name = [1]
The __init__ method assigns the parameter name to the instance variable self.name.
Complete the code to add an expense to the Group's expenses list.
class Group: def __init__(self): self.expenses = [] def add_expense(self, expense): self.expenses.[1](expense)
The append method adds a single item to the end of a list.
Fix the error in the Expense class constructor to correctly assign amount.
class Expense: def __init__(self, amount): self.amount = [1]
The constructor should assign the parameter amount to the instance variable self.amount.
Fill both blanks to create a method in Group that calculates total expenses.
class Group: def __init__(self): self.expenses = [] def total_expense(self): return sum(expense.[1] for expense in self.[2])
The method sums the amount attribute of each expense in the expenses list.
Fill all three blanks to create a method in User that adds a group and records the user's name.
class User: def __init__(self, name): self.name = name self.groups = [] def join_group(self, group): self.groups.[1](group) print(f"[2] joined [3]")
The method appends the group to the user's groups list and prints a message with the user's name and group's name.