File tree 1 file changed +9
-15
lines changed
1 file changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -31,28 +31,22 @@ def decrypt(message: str) -> None:
31
31
Decryption using Key #24: VOFGVWZ ROFXW
32
32
Decryption using Key #25: UNEFUVY QNEWV
33
33
"""
34
- for key in range (len ( string . ascii_uppercase ) ):
35
- translated = ""
34
+ for key in range (alphabet_len ):
35
+ translated = []
36
36
for symbol in message :
37
- if symbol in string .ascii_uppercase :
38
- num = string .ascii_uppercase .find (symbol )
39
- num = num - key
40
- if num < 0 :
41
- num = num + len (string .ascii_uppercase )
42
- translated = translated + string .ascii_uppercase [num ]
37
+ if symbol in alphabet :
38
+ num = alphabet .find (symbol ) - key
39
+ translated .append (alphabet [num % alphabet_len ])
43
40
else :
44
- translated = translated + symbol
45
- print (f"Decryption using Key #{ key } : { translated } " )
41
+ translated . append ( symbol )
42
+ print (f"Decryption using Key #{ key } : { '' . join ( translated ) } " )
46
43
47
44
48
45
def main () -> None :
49
- message = input ("Encrypted message: " )
50
- message = message .upper ()
46
+ message = input ("Encrypted message: " ).upper ()
51
47
decrypt (message )
52
48
53
-
54
49
if __name__ == "__main__" :
55
50
import doctest
56
-
57
51
doctest .testmod ()
58
- main ()
52
+ main ()
You can’t perform that action at this time.
0 commit comments