In this case, it reduces the clutter that print(".", var, ".", var, ".") causes. I would use f"" strings so you can directly format your variables in your strings.
I'm going to step through each line of the main function now.
lower() on the input to change the string to all lowercase letters. Instead of trusting the user will only enter lowercase characters after telling them to do so, call. Since you're working with the alphabet, it will return the position of the character in that string. Index returns the first occurrence of the character in question. with the following: alphabets.index(character) + 1 Your position_in_alphabets function can be reduced to one line. Print ("The word which is coded as ",given," is : ",output) Given = input("Please enter the word to be decrypted : ") Print ("NOTE : Please enter just lowercase characters (no special characters) and no spaces")
#Simple email program for python code#
Python Code : alphabets = 'abcdefghijklmnopqrstuvwxyz' Please let me know what you think about this program Thank You for the suggestions on the previous program, it helped me reduce the length of this program by 16 lines.
I got a lot of suggestions from people on the encryption post, I have tried to make this program as short as possible (in my efforts), I did not use the method they suggested to shorten functions because I don't want to use it without understanding how it works, I will implement it in my further programs as soon as I understand it. This is a program that can decrypt the codes that have been encrypted using the algorithm that my previously posted encryption program follows, you just need to enter the encrypted text from that program.