Skip to content

Commit 698cf30

Browse files
committed
refactor: Replace char constant with string.ascii_uppercase
1 parent db1007b commit 698cf30

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ciphers/brute_force_caesar_cipher.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1+
import string
22

33

44
def decrypt(message: str) -> None:
@@ -31,15 +31,15 @@ def decrypt(message: str) -> None:
3131
Decryption using Key #24: VOFGVWZ ROFXW
3232
Decryption using Key #25: UNEFUVY QNEWV
3333
"""
34-
for key in range(len(LETTERS)):
34+
for key in range(len(string.ascii_uppercase)):
3535
translated = ""
3636
for symbol in message:
37-
if symbol in LETTERS:
38-
num = LETTERS.find(symbol)
37+
if symbol in string.ascii_uppercase:
38+
num = string.ascii_uppercase.find(symbol)
3939
num = num - key
4040
if num < 0:
41-
num = num + len(LETTERS)
42-
translated = translated + LETTERS[num]
41+
num = num + len(string.ascii_uppercase)
42+
translated = translated + string.ascii_uppercase[num]
4343
else:
4444
translated = translated + symbol
4545
print(f"Decryption using Key #{key}: {translated}")

0 commit comments

Comments
 (0)