def intersperse(string, counts, separator=''):
 (left, rest, right) = intersperse_pat.match(string).groups()
 def reverse(s):
  return s[::(-1)]
 splits = split(reverse(rest), counts)
 res = separator.join(map(reverse, reverse(splits)))
 return (((left + res) + right), (((len(splits) > 0) and (len(splits) - 1)) or 0))

def intersperse ( string , counts , separator = '' ) : ( left , rest , right ) = intersperse_pat . match ( string ) . groups ( ) def reverse ( s ) : return s [ : : ( - 1 ) ] splits = split ( reverse ( rest ) , counts ) res = separator . join ( map ( reverse , reverse ( splits ) ) ) return ( ( ( left + res ) + right ) , ( ( ( len ( splits ) > 0 ) and ( len ( splits ) - 1 ) ) or 0 ) )
see the asserts below for examples .