Computer Science | Artificial Intelligence | Computational Biology | Chess | Blender
import string # Char for recognizing the alphabet char = string.ascii_letters + string.digits + string.punctuation + ' ' # Key used as a template for encryption key = string.punctuation + string.digits + " " + string.ascii_letters # Text to be encrypted text = input('Enter the text to be encrypted: ') # Encrypt the text function def encrypt(text): encrypted_text = '' for i in text: encrypted_text += key[char.find(i)] return encrypted_text # Call and print the encrypted text print(encrypt(text))