i, n = 0, len(strng)
while i < n:
    match = False
for s, r in list(replace.items()):
    if strng[i:len(s) + i] == s:
        buffer.append(r)
i = i + len(s)
match = True
break
if not match:
    buffer.append(strng[i])
i = i + 1
return ''.join(buffer)
php's strtr for python