Cleaned. You can remove the 'else's if you want, because 'return' breaks the instruction flow. Should also work with other sequence types.
---------------- def mySubst(reps,seq): if reps: a,b,c = string.partition(reps[0][0]) if b: return mySubst(reps,a) + reps[0][1] + mySubst (reps,c) else: return mySubst(reps[1:], seq) else: return seq print mySubst( ( ('foo','bar'), ('bar','qux'), ('qux','foo') ), 'foobarquxfoo') print mySubst( ( ('foo','bar'), ('bar','qux'), ('qux','foo') ), 'foobarquxxxfoo') ------- Wyrmskull -- http://mail.python.org/mailman/listinfo/python-list