We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 93067ce commit b47b1e7Copy full SHA for b47b1e7
Ciphers/rot13.py
@@ -0,0 +1,21 @@
1
+#rot13
2
+OFFSET_LOWER = ord('a')
3
+OFFSET_UPPER = ord('A')
4
+
5
+def rot13(text):
6
+ rot13_text = ''
7
+ for i in range(len(text)):
8
+ ch = text[i]
9
+ if ch.isalpha():
10
+ if(ch.islower()):
11
+ offset = OFFSET_LOWER
12
+ else:
13
+ offset = OFFSET_UPPER
14
+ rot13_text += chr(((ord(ch)-offset+13)%26+offset))
15
16
+ rot13_text += ch
17
+ return rot13_text
18
19
+plain_text = input("Enter the string: ")
20
+print(rot13(plain_text))
21
+print(rot13(rot13(plain_text)))
0 commit comments