Skip to content

Commit 43ed0c0

Browse files
committed
Finished working on the rotational-cipher challenge
1 parent dfeffff commit 43ed0c0

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed
485 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
def rotate(text, key):
2-
pass
2+
3+
result = ""
4+
# transverse the plain text
5+
for i in range(len(text)):
6+
char = text[i]
7+
# Encrypt uppercase characters in plain text
8+
9+
if (char.isalpha() == False):
10+
result += char
11+
12+
elif (char.isupper()):
13+
result += chr((ord(char) + key - 65) % 26 + 65)
14+
15+
else:
16+
result += chr((ord(char) + key - 97) % 26 + 97)
17+
18+
return result

0 commit comments

Comments
 (0)