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‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1+
try: # Python 2
2+
raw_input
3+
unichr
4+
exceptNameError: # Python 3
5+
raw_input=input
6+
unichr=chr
7+
8+
19
defAtbash():
2-
inp=raw_input("Enter the sentence to be encrypted ")
310
output=""
4-
foriininp:
5-
extract=ord(i)
6-
ifextract>=65andextract<=90:
7-
output+=(unichr(155-extract))
8-
elifextract>=97andextract<=122:
9-
output+=(unichr(219-extract))
11+
foriinraw_input("Enter the sentence to be encrypted ").strip():
12+
extract=ord(i)
13+
if65<=extract<=90:
14+
output+=unichr(155-extract)
15+
elif97<=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)