File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
- def dencrypt (s : str , n : int = 13 ) -> str :
1
+ def dencrypt (s : str ) -> str :
2
2
"""
3
3
https://en.wikipedia.org/wiki/ROT13
4
4
@@ -9,24 +9,25 @@ def dencrypt(s: str, n: int = 13) -> str:
9
9
>>> dencrypt(s) == msg
10
10
True
11
11
"""
12
- out = ""
12
+ out = []
13
+ n = 13
13
14
for c in s :
14
15
if "A" <= c <= "Z" :
15
16
out += chr (ord ("A" ) + (ord (c ) - ord ("A" ) + n ) % 26 )
16
17
elif "a" <= c <= "z" :
17
18
out += chr (ord ("a" ) + (ord (c ) - ord ("a" ) + n ) % 26 )
18
19
else :
19
20
out += c
20
- return out
21
+ return '' . join ( out )
21
22
22
23
23
24
def main () -> None :
24
25
s0 = input ("Enter message: " )
25
26
26
- s1 = dencrypt (s0 , 13 )
27
+ s1 = dencrypt (s0 )
27
28
print ("Encryption:" , s1 )
28
29
29
- s2 = dencrypt (s1 , 13 )
30
+ s2 = dencrypt (s1 )
30
31
print ("Decryption: " , s2 )
31
32
32
33
You can’t perform that action at this time.
0 commit comments