-
Notifications
You must be signed in to change notification settings - Fork 1
/
rot13-1.0.py
17 lines (17 loc) · 1.01 KB
/
rot13-1.0.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def encrypt(string):
firstHalfLetters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"]
lastHalfLetters = ["N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
encryptedString = ""
selectedLetter = 0
for x in range(len(string)):
if string[selectedLetter] not in firstHalfLetters and string[selectedLetter] not in lastHalfLetters:
encryptedString += string[selectedLetter]
selectedLetter += 1
else:
if string[selectedLetter] in firstHalfLetters:
encryptedString += lastHalfLetters[firstHalfLetters.index(string[selectedLetter])]
selectedLetter += 1
elif string[selectedLetter] in lastHalfLetters:
encryptedString += firstHalfLetters[lastHalfLetters.index(string[selectedLetter])]
selectedLetter += 1
return encryptedString