def get_lineup_number(players: list[dict], prompt: str) -> int:
    """Get the player by lineup number and confirm it is a valid lineup number."""
    while True:
        try:
            number: int = int(input(prompt))
        except ValueError:
            print("Invalid integer. Please try again.")
            continue
        if number < 1 or number > len(players):
            print("Invalid player number. " +
                  "Please try again.")
        else:
            break

    return number