game_utils.py 1.83 KB
UPPERCASE_LETTERS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
                     "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
LOWERCASE_LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
                     "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]


def to_uppercase(letter: str) -> str:
    if letter in LOWERCASE_LETTERS:
        # swap it out for the uppercase version
        idx: int = LOWERCASE_LETTERS.index(letter)
        upper_version: str = UPPERCASE_LETTERS[idx]
        return upper_version
    return letter


def uppercase(word: str) -> str:
    """
    Returns a new version of `word` where every letter is uppercased.

    Args:
        word (str): The string to uppercase

    Returns:
        str: The uppercased version of `word`
    """
    ...


def ask_for_choice(prompt: str, valid_choices: list[str]) -> str | None:
    """
    Repeatedly prompts the user asking them to make a choice that is
    a member of `valid_choices`.

    Args:
        prompt (str): The prompt to give the user
        valid_choices (list[str]): A list of valid choices

    Returns:
        str: The choice the user inputed
    """
    ...


def is_answer(s: str | None, yn: set[str]) -> bool:
    """
    Returns True when `s` is a member of `yn` and False otherwise

    Args:
        s(str | None): The string to test
        yn(set): A set of potential valid answers

    Returns:
        bool: True iff `s` in `yn`
    """
    ...

    
def prompt_yes_no(prompt: str) -> bool:
    """
    Repeatedly prompts the user with prompt until they respond with
    an answer starting with y or n. 

    Args:
        prompt (str): The prompt to give to the user

    Returns:
        bool: Returns True when the user eventually inputs y and False when they input n.
    """
    ...