Guest User

Untitled

a guest
Jul 15th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import string
  2. def Enigma(conversion):
  3. alpha = ['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']
  4. result = ""
  5. l = len(conversion)
  6. i = 0
  7. usernum=int(raw_input("Insert a number you wish to shift the alphabet by: "))
  8. if usernum>= 26:
  9. usernum= usernum%26
  10. while i < l :
  11. try:
  12. result += alpha[(alpha.index(conversion[i])+usernum)]
  13. i += 1
  14. except:
  15. result += conversion[i]
  16. i+=1
  17. return result
  18.  
  19. conversion=string.upper(raw_input("Insert a message to be encoded: "))
  20. while conversion[0] != ".":
  21. print Enigma(conversion)
  22. conversion=string.upper(raw_input("Insert a message to be encoded: "))
  23. print "Bye!"
Add Comment
Please, Sign In to add comment