Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alphabet = ('abcdefghijklmnopqrstuvwxyz')
- newalphabet = {}
- def moveword(offset):
- for i in range (0, 26):
- letter = alphabet[i]
- newalphabet[letter]= alphabet[(i + offset) % 26]
- def encryptbasic(sentence):
- output =""
- for letter in sentence:
- if letter in alphabet:
- letter = newalphabet[letter]
- output+= letter
- else:
- output+= " "
- print(output)
- def encrypt():
- sentance = input('Enter sentance: ')
- offset = int(input('Enter offset: '))
- alphabet = ('abcdefghijklmnopqrstuvwxyz')
- output = ''
- if offset ==0:
- for e in range(1, 26):
- moveword(e)
- encryptbasic(sentance)
- else:
- for c in sentance:
- if c in alphabet:
- output += alphabet[(alphabet.find(c) + offset) % (len(alphabet))]
- else:
- output += c
- print('Your encrypted message is: ' + output)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement