We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0a5e53e commit 26c8b34Copy full SHA for 26c8b34
Caesar cipher.py
@@ -1,14 +1,14 @@
1
def encrypt(letter, s):
2
if (letter.isupper()):
3
- return chr((ord(letter) + s - 65) % 26 + 65)
+ return chr((ord(letter) + s - 65) % 26 + 65) #for uppercase input string
4
elif (letter.islower()):
5
- return chr((ord(letter) + s - 97) % 26 + 97)
+ return chr((ord(letter) + s - 97) % 26 + 97) #for smallercase input string
6
else:
7
return letter
8
9
text = input("Enter the word: ")
10
s = int(input("Enter the shift: "))
11
-shift = [s] * len(text)
+shift = [s] * len(text) #shifts the alphabet by input spaces in the english alphabet
12
result = list(map(encrypt, text, shift))
13
14
print("Encrypted text: ", end="")
0 commit comments