def find_in_set(query, string_list):
    """Return the index (1-based!) of `query` in `string_list`.

    Analagous to the FIND_IN_SET function in MySQL.

    Examples
    --------
    >>> find_in_set(10, '1,3,5,10')
    4
    >>> find_in_set('40', ',,,20,,30,40')
    7
    >>> find_in_set(2, '1,3,5')
    0
    """
    try:
        return string_list.split(',').index(str(query)) + 1
    except ValueError:
        return 0
