Skip to content

Commit 1ff77c1

Browse files
Fix:Used list instead of string in rot13.py and removed n
1 parent 3e9ca92 commit 1ff77c1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ciphers/rot13.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def dencrypt(s: str, n: int = 13) -> str:
1+
def dencrypt(s: str) -> str:
22
"""
33
https://en.wikipedia.org/wiki/ROT13
44
@@ -9,24 +9,25 @@ def dencrypt(s: str, n: int = 13) -> str:
99
>>> dencrypt(s) == msg
1010
True
1111
"""
12-
out = ""
12+
out = []
13+
n=13
1314
for c in s:
1415
if "A" <= c <= "Z":
1516
out += chr(ord("A") + (ord(c) - ord("A") + n) % 26)
1617
elif "a" <= c <= "z":
1718
out += chr(ord("a") + (ord(c) - ord("a") + n) % 26)
1819
else:
1920
out += c
20-
return out
21+
return ''.join(out)
2122

2223

2324
def main() -> None:
2425
s0 = input("Enter message: ")
2526

26-
s1 = dencrypt(s0, 13)
27+
s1 = dencrypt(s0)
2728
print("Encryption:", s1)
2829

29-
s2 = dencrypt(s1, 13)
30+
s2 = dencrypt(s1)
3031
print("Decryption: ", s2)
3132

3233

0 commit comments

Comments
 (0)