def trunc_at(s, d, n=3):
    """Returns s truncated at the n'th (3rd by default) occurrence of the delimiter, d."""
return d.join(s.split(d)[:n])
print(trunc_at('115Z2113-3-777-55789ABC7777', '-'))
Strip string after third occurrence of character python