def get_all_inds(string, substr):
    """Returns indices of all occurrences of a substring."""
    # initialize list of indices of occurrences with dummy entry
    inds = [0]
    # find first occurrence
    i_curr = string.find(substr)
    # while end of string has not been reached
    while i_curr != -1:
        # determine true index by adding spacing to last index
        inds += [i_curr + inds[-1]]
        # cut off string to current character because .find(substr) will only
        # return the first occurrence
        string = string[inds[-1]:]
        # find next occurrence in string
        i_curr = string.find(substr)
    # If no entries have been added, return 0 as sentinel
    if len(inds) == 1:
        result = 0
    # otherwise, cutoff dummy entry at first position before returning result
    else:
        result = inds[1:]

    return result