Skip to content

Commit 26c8b34

Browse files
authored
Update Caesar cipher.py
1 parent 0a5e53e commit 26c8b34

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Caesar cipher.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
def encrypt(letter, s):
22
if (letter.isupper()):
3-
return chr((ord(letter) + s - 65) % 26 + 65)
3+
return chr((ord(letter) + s - 65) % 26 + 65) #for uppercase input string
44
elif (letter.islower()):
5-
return chr((ord(letter) + s - 97) % 26 + 97)
5+
return chr((ord(letter) + s - 97) % 26 + 97) #for smallercase input string
66
else:
77
return letter
88

99
text = input("Enter the word: ")
1010
s = int(input("Enter the shift: "))
11-
shift = [s] * len(text)
11+
shift = [s] * len(text) #shifts the alphabet by input spaces in the english alphabet
1212
result = list(map(encrypt, text, shift))
1313

1414
print("Encrypted text: ", end="")

0 commit comments

Comments
 (0)