Fan or not

Report a typo

Implement a function add_viewer() for an esports tournament viewing party. This function should handle two types of viewers: fans of specific teams and general viewers.

The function should:

  1. Accept two parameters:

    • name: A string representing the person's name (required)

    • fan_list: An optional list of existing fans (if a person does not have a favorite team yet, this argument should not be passed to the function)

  2. Behave as follows:

    • If fan_list is provided, add the name to this list and return the updated list.

    • If fan_list is not provided (a person is not a fan of any particular team), create a new list with only the name and return it.

You only need to implement the function. Do not handle input or call the function in your code.

Write a program in Python 3
def add_viewer(...):
...
___

Create a free account to access the full topic