def cipher(s):
res = ''
ia = ord('a')
iz = ord('z')
iA = ord('A')
iZ = ord('Z')
for ch in s:
i = ord(ch)
if ia <= i <= iz:
res += chr(iz -(i-ia))
elif iA <= i <= iZ:
res += chr(iZ -(i-iA))
else:
res += ch
return res
def main():
line = input('Enter a string - ')
secret = cipher(line)
print('Secret message is', secret)
if __name__== '__main__':
main()
Comments
Leave a comment