I'm trying to map one letter to another in Python 3. But I'm getting the wrong output. Here's one of the test inputs:
txt = 'wlgp le scd wlgp'
output should be:
pick is the pick
But I'm getting this wrong output:
pick it tht pick
Here's my code:
def swapCharacters(txt):
hash = {'c':'h', 'd':'e', 'e':'s', 'g':'c', 'l':'i', 'p':'k', 's':'t', 'w':'p'}
for key in hash.keys():
txt = txt.replace(key, hash[key])
print(txt)