Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- def Enigma(conversion):
- 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']
- result = ""
- l = len(conversion)
- i = 0
- usernum=int(raw_input("Insert a number you wish to shift the alphabet by: "))
- if usernum>= 26:
- usernum= usernum%26
- while i < l :
- try:
- result += alpha[(alpha.index(conversion[i])+usernum)]
- i += 1
- except:
- result += conversion[i]
- i+=1
- return result
- conversion=string.upper(raw_input("Insert a message to be encoded: "))
- while conversion[0] != ".":
- print Enigma(conversion)
- conversion=string.upper(raw_input("Insert a message to be encoded: "))
- print "Bye!"
Add Comment
Please, Sign In to add comment