rohittigga

Untitled

Dec 9th, 2016
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. def caesar(plainText, shift):
  2.   cipherText = ""
  3.   for ch in plainText:
  4.     if ch.isalpha():
  5.       stayInAlphabet = ord(ch) + shift
  6.       if stayInAlphabet > ord('z'):
  7.         stayInAlphabet -= 26
  8.       finalLetter = chr(stayInAlphabet)
  9.       cipherText += finalLetter
  10.   print "Your ciphertext is: ", cipherText
  11.   return cipherText
Advertisement
Add Comment
Please, Sign In to add comment