Created
June 6, 2017 01:51
-
-
Save sblack4/c4f6ba7a3971c107651353bf251e4ac3 to your computer and use it in GitHub Desktop.
gets a word from the command line and decodes it using a ceasar cipher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, string | |
def getDecodedLetter(encoded, n): | |
position = string.ascii_lowercase.index(encoded) | |
return string.ascii_lowercase[(position + n) % 26] | |
def getDecodedWord(word, n): | |
decodedWord = "" | |
for letter in word: | |
decodedWord += getDecodedLetter(letter, n) | |
return decodedWord | |
def iterateOver(word): | |
for i in range(1,26): | |
print(str(i) + " " + getDecodedWord(word, i)) | |
if __name__ == "__main__": | |
for word in sys.argv[1:]: | |
print(word) | |
iterateOver(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment