- Initializing mapping
mapping = {' ': ' '}- Create mapping
i = 0
letters = 'abcdefghijklmnopqrstuvwxyz'
for char in key:
if char not in mapping:
mapping[char] = letters[i]
i += 1- Using mapping
res = ''
for char in message:
res += mapping[char]