I have this program where I want to convert a normal message, to an encrypted one. In the program, it replaces each letter with it's opposite. When it changes from
c = c.replace('n','m') then it replaces all of the ones it replaced before.
def convert(c):
c = c.replace('a', 'z')
c = c.replace('b', 'y')
c = c.replace('c', 'x')
c = c.replace('d', 'w')
c = c.replace('e', 'v')
c = c.replace('f', 'u')
c = c.replace('g', 't')
c = c.replace('h', 's')
c = c.replace('i', 'r')
c = c.replace('j', 'q')
c = c.replace('k', 'p')
c = c.replace('l', 'o')
c = c.replace('m', 'n')
c = c.replace('n', 'm')
c = c.replace('o', 'l')
c = c.replace('p', 'k')
c = c.replace('q', 'j')
c = c.replace('r', 'i')
c = c.replace('s', 'h')
c = c.replace('t', 'g')
c = c.replace('u', 'f')
c = c.replace('v', 'e')
c = c.replace('w', 'd')
c = c.replace('x', 'c')
c = c.replace('y', 'b')
c = c.replace('z', 'a')
return c
print(convert('the quick brown fox jumps over the lazy dog'))
And the output is :
ghe jfick bildm flc jfmkh leei ghe laab dlg
It doesn't convert all the letters. Can someone please help??
h -> s -> h, butt -> g