def create_unique_id(prefix, existing_ids):
    """Return a unique string ID from the prefix.

    First check if the prefix is itself a unique ID in the set-like parameter
    existing_ids. If not, try integers in ascending order appended to the
    prefix until a unique ID is found.
    """
    if prefix in existing_ids:
        suffix = 1
        while True:
            new_id = '{}_{}'.format(prefix, suffix)
            if new_id not in existing_ids:
                return new_id
            suffix += 1

    return prefix
def create_unique_id ( prefix , existing_ids ) : if prefix in existing_ids : suffix = 1 while True : new_id = '{}_{}' . format ( prefix , suffix ) if new_id not in existing_ids : return new_id suffix += 1 return prefix
Return a unique string ID from the prefix.

    First check if the prefix is itself a unique ID in the set-like parameter
    existing_ids. If not, try integers in ascending order appended to the
    prefix until a unique ID is found.