mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
Atbash.py: Both raw_input() and unichr() were removed in Python 3 (#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
This commit is contained in:
parent
f9b8dbf9db
commit
0f229e0870
@ -1,14 +1,21 @@
|
|||||||
|
try: # Python 2
|
||||||
|
raw_input
|
||||||
|
unichr
|
||||||
|
except NameError: # Python 3
|
||||||
|
raw_input = input
|
||||||
|
unichr = chr
|
||||||
|
|
||||||
|
|
||||||
def Atbash():
|
def Atbash():
|
||||||
inp=raw_input("Enter the sentence to be encrypted ")
|
|
||||||
output=""
|
output=""
|
||||||
for i in inp:
|
for i in raw_input("Enter the sentence to be encrypted ").strip():
|
||||||
extract=ord(i)
|
extract = ord(i)
|
||||||
if extract>=65 and extract<=90:
|
if 65 <= extract <= 90:
|
||||||
output+=(unichr(155-extract))
|
output += unichr(155-extract)
|
||||||
elif extract>=97 and extract<=122:
|
elif 97 <= extract <= 122:
|
||||||
output+=(unichr(219-extract))
|
output += unichr(219-extract)
|
||||||
else:
|
else:
|
||||||
output+=i
|
output+=i
|
||||||
print (output)
|
print(output)
|
||||||
|
|
||||||
Atbash() ;
|
Atbash()
|
||||||
|
Loading…
Reference in New Issue
Block a user