Answer:
class ShoppingList:
def __init__(self):
self.products = []
def add_product(self, product):
self.products.append(product)
def remove_product(self, product):
if product in self.products:
self.products.remove(product)
else:
print(f"{product} is not in the shopping list.")
def view_list(self):
print("Shopping List:")
for product in self.products:
print(product)
def clear_list(self):
self.products = []
def check_off(self, product):
if product in self.products:
print(f"Checking off {product} from the shopping list.")
# Perform any additional actions for checking off a product
else:
print(f"{product} is not in the shopping list.")
# Example usage:
shopping_list = ShoppingList()
# Add products to the shopping list
shopping_list.add_product('Apples')
shopping_list.add_product('Milk')
shopping_list.add_product('Bread')
# View the shopping list
shopping_list.view_list()
# Remove a product from the shopping list
shopping_list.remove_product('Milk')
# View the updated shopping list
shopping_list.view_list()
# Check off a product from the shopping list
shopping_list.check_off('Bread')
# Clear the shopping list
shopping_list.clear_list()
# View the empty shopping list
shopping_list.view_list()