mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-04-08 14:55:53 +00:00
Fix:Used list instead of string in rot13.py and removed n
This commit is contained in:
parent
3e9ca92ca9
commit
1ff77c1612
@ -1,4 +1,4 @@
|
||||
def dencrypt(s: str, n: int = 13) -> str:
|
||||
def dencrypt(s: str) -> str:
|
||||
"""
|
||||
https://en.wikipedia.org/wiki/ROT13
|
||||
|
||||
@ -9,7 +9,8 @@ def dencrypt(s: str, n: int = 13) -> str:
|
||||
>>> dencrypt(s) == msg
|
||||
True
|
||||
"""
|
||||
out = ""
|
||||
out = []
|
||||
n=13
|
||||
for c in s:
|
||||
if "A" <= c <= "Z":
|
||||
out += chr(ord("A") + (ord(c) - ord("A") + n) % 26)
|
||||
@ -17,16 +18,16 @@ def dencrypt(s: str, n: int = 13) -> str:
|
||||
out += chr(ord("a") + (ord(c) - ord("a") + n) % 26)
|
||||
else:
|
||||
out += c
|
||||
return out
|
||||
return ''.join(out)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
s0 = input("Enter message: ")
|
||||
|
||||
s1 = dencrypt(s0, 13)
|
||||
s1 = dencrypt(s0)
|
||||
print("Encryption:", s1)
|
||||
|
||||
s2 = dencrypt(s1, 13)
|
||||
s2 = dencrypt(s1)
|
||||
print("Decryption: ", s2)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user