def prompt_for_offense_id():
    """
    Prompts the user to enter an offense ID. They could optionally enter "next"
    to indicate they want to see another five offenses, or "quit" to terminate
    the sample. Loops until the user enters valid input.
    """

    # Loop until the user enters valid input.
    offense_id = None
    while offense_id is None:

        offense_id = input(
            "Enter an offense id, next to see another five offenses, or "
            "quit to terminate the sample: ").strip()

        if offense_id == "quit":

            # The user has requested to terminate the sample.
            return None

        # Verify the user has either entered "next" or a valid offense ID.
        offense_id_valid = True
        if offense_id != "next":
            try:
                offense_id_int = int(offense_id)
                if offense_id_int < 0:
                    offense_id_valid = False
            except ValueError:
                offense_id_valid = False

        if not offense_id_valid:

            # If the input was not valid then print a message and continue the
            # loop.
            print(offense_id + " is not valid input.")
            offense_id = None
            continue

    return offense_id
dataset/ETHPy150Open ibm-security-intelligence/api-samples/siem/08_GetOffenseAddresses.py/prompt_for_offense_id/original