def find_nth(s, x, n):
    """
    find the nth occurence in a string
    takes string where to search, substring, nth-occurence
    """
    i = -1
    for _ in range(n):
        i = s.find(x, i + len(x))
        if i == -1:
            break
    return i