Skip to content

Commit 0f229e0

Browse files
cclausspoyea
authored andcommitted
Atbash.py: Both raw_input() and unichr() were removed in Python 3 (TheAlgorithms#855)
* Atbash.py: Both raw_input() and unichr() were removed in Python 3 @sateslayer and @AnupKumarPanwar your reviews please. * Remove any leading / trailing whitespace from user input
1 parent f9b8dbf commit 0f229e0

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

ciphers/Atbash.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
try: # Python 2
2+
raw_input
3+
unichr
4+
except NameError: # Python 3
5+
raw_input = input
6+
unichr = chr
7+
8+
19
def Atbash():
2-
inp=raw_input("Enter the sentence to be encrypted ")
310
output=""
4-
for i in inp:
5-
extract=ord(i)
6-
if extract>=65 and extract<=90:
7-
output+=(unichr(155-extract))
8-
elif extract>=97 and extract<=122:
9-
output+=(unichr(219-extract))
11+
for i in raw_input("Enter the sentence to be encrypted ").strip():
12+
extract = ord(i)
13+
if 65 <= extract <= 90:
14+
output += unichr(155-extract)
15+
elif 97 <= extract <= 122:
16+
output += unichr(219-extract)
1017
else:
1118
output+=i
12-
print (output)
19+
print(output)
1320

14-
Atbash() ;
21+
Atbash()

0 commit comments

Comments
 (0)