mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python * sort() --> sorted()
This commit is contained in:
@ -1,23 +1,15 @@
|
||||
try: # Python 2
|
||||
raw_input
|
||||
unichr
|
||||
except NameError: # Python 3
|
||||
raw_input = input
|
||||
unichr = chr
|
||||
|
||||
|
||||
def Atbash():
|
||||
def atbash():
|
||||
output=""
|
||||
for i in raw_input("Enter the sentence to be encrypted ").strip():
|
||||
for i in input("Enter the sentence to be encrypted ").strip():
|
||||
extract = ord(i)
|
||||
if 65 <= extract <= 90:
|
||||
output += unichr(155-extract)
|
||||
output += chr(155-extract)
|
||||
elif 97 <= extract <= 122:
|
||||
output += unichr(219-extract)
|
||||
output += chr(219-extract)
|
||||
else:
|
||||
output+=i
|
||||
output += i
|
||||
print(output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
Atbash()
|
||||
atbash()
|
||||
|
Reference in New Issue
Block a user