# Python 3, 50 bytes lambda s,k:s.translate(dict(zip(range(97,122),k))) Or if we really have to implement an infinite loop: # Python 3, 70 bytes t=dict(zip(range(97,122),input())) while 1:print(input().translate(t))