I'm newbie in Python and I wrote a tool called Caesar Encryption Tool. At the moment it only encrypts. It takes a plain text and a key from the user then encrypts the plain text using the key. How can this code be improved?
# This is version 1.0 Caesar Encryption Tool and it will be improved. # This tool is written by Mahmoud Naguib. # My facebook account is at : https:\\www.facebook.com\naguibarea # This is letters table. lettersTable = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] # This line takes the user's key it's 3 by default. key = int(input('Enter your key : ')) # This line takes the user's plain text and converts it # to uppercase to search for it in the English alphabet. plainText = input('Enter your plain text : ').upper() for letter in range(len(plainText)): # If there is a letter which isn't alphabet like numbers, # special characters and spaces it will be appended to the list. if plainText[letter] not in lettersTable: lettersTable.append(plainText[letter]) # This line locates the plain letter's numeric value in other words its position. position = lettersTable.index(plainText[letter]) # This line adds the key entered by the user to the plain letter's # numeric value to reach the new encrypted letter. step = position + key # if the encrypted letter's numeric value is greater than 25 # then its new numeric value is the old numeric valuu % # the number of English alphabet letters. if step > 25: step %= 26 # If position is greater than 25 that means it's not an alphabet # value and it will be printed without adding the key. if position > 25: step = position # This line locates the encrypted letter's numeric value in other words # its position and prints the encrypted letter. # end is a keyword argument to combine all letters together. print(lettersTable[step], end='')