Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shift = raw_input ("Enter a value to shift the alphabet by... ")
- alphaDict = {}
- alphaList = ['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']
- for shift in alphaList:
- alphaList.append (alphaDict)
- alphaDict = 'a'
- alphaDict = chr(ord( What value would go here? + 1)
- letter = "A"
- letter = chr(ord(letter) + 1)
- # letter is now "B"
- def caesar(s, k, decode = False):
- if decode: k = 26 - k
- return "".join([chr((ord(i) - 65 + k) % 26 + 65)
- for i in s.upper()
- if ord(i) >= 65 and ord(i) <= 90 ])
- msg = "The quick brown fox jumped over the lazy dogs"
- print msg
- enc = caesar(msg, 11)
- print enc
- print caesar(enc, 11, decode = True)
- print "Enter senctence: "
- sentence = raw_input()
- print "Enter shift: "
- shift = raw_input()
- result = ""
- for letter in sentence:
- ascii = (ord(letter) + int(shift))%123
- if ascii < 97:
- ascii = ascii + 97
- result = result + chr(ascii)
- print result
- import string # import library
- try:
- shift = int(raw_input ('Enter a value to shift the alphabet by... ')) # set amount of shift
- except ValueError: # if an integer is not entered
- print 'You must enter an integer!'
- table = string.maketrans(string.lowercase, string.lowercase[shift:]+string.lowercase[:shift]) # make a translation table from abc...xyz shifted letters
- text = raw_input('Enter Text: ') # get input
- print text.translate(table); # print translation
- import string # import library
- try:
- shift = int(raw_input ('Enter a value to shift the alphabet by... ')) # set amount of shift
- except ValueError: # if an integer is not entered
- print 'You must enter an integer!'
- table = string.maketrans(string.lowercase, string.lowercase[shift:]+string.lowercase[:shift]) # make a translation table from abc...xyz shifted letters
- print text.translate(string.lowercase); # print translation
Add Comment
Please, Sign In to add comment