Advertisement
Adehumble

Week4 Coding Exercise 13

Feb 22nd, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #13
  2. print("This program is written to encrypt your input by changing each characters in your word to a corresponding character by stepping it by postion two in the English alphabet.\nDon't mind my epistle. Let's play a game!")
  3. print("|||||"*24)
  4.  
  5. #I am going to be demonstrating the functionality of this code by allowing a any dynamic input from my user, be it in lowercases or uppercases
  6.  
  7.  
  8. #My Function Program
  9. def encrypt_message(message):
  10.     encrypted=" "
  11.     alphabets=["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"]
  12.    
  13.     for letter in message:
  14.         index1=alphabets.index(letter)
  15.         if index1<=23:
  16.             index2=index1+2
  17.             encrypted=encrypted+alphabets[index2]
  18.         elif index1==24:
  19.             encrypted=encrypted+alphabets[0]
  20.         elif index1==25:
  21.             encrypted=encrypted+alphabets[1]
  22.     print(encrypted)
  23.    
  24.  
  25. #My Main Program
  26. user_word=input("Enter any word you wish to encrypt: ").lower()
  27. print("Your new encrypted word is: ")
  28. encrypt_message(user_word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement