21 lines
609 B
Python
Executable File
21 lines
609 B
Python
Executable File
#!/usr/bin/env python3
|
||
import sys
|
||
|
||
en = "qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?"
|
||
ru = "йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,"
|
||
|
||
def toggle(text):
|
||
if any('а' <= c <= 'я' or 'А' <= c <= 'Я' for c in text):
|
||
trans = str.maketrans(ru, en)
|
||
else:
|
||
trans = str.maketrans(en, ru)
|
||
return text.translate(trans)
|
||
|
||
if len(sys.argv) > 1:
|
||
input_text = " ".join(sys.argv[1:])
|
||
else:
|
||
input_text = sys.stdin.read().strip()
|
||
|
||
if input_text:
|
||
print(toggle(input_text))
|