Alphabet Half-Shift
ROT-13 is a simple cipher where each Latin letter is replaced by the letter 13 positions later in the alphabet. Write a function rot13 that keeps the original case: uppercase letters stay uppercase, and lowercase letters stay lowercase. Leave all non-Latin letters and other characters unchanged. A neat property of ROT-13 is that applying it twice gives back the original string.
Примеры
Ввод
"Hello"Вывод
"Uryyb"Ввод
"Uryyb"Вывод
"Hello"Ввод
"abc"Вывод
"nop"Нужно реализовать
def rot13(s: str) -> str:
Теги
strings
Conectează-te pentru a vedea istoricul soluțiilor trimise
Conectează-teConectează-te pentru a folosi Mentorul AI
Conectează-teVisible tests
1
Input
"Hello"Expected
"Uryyb"2
Input
"Uryyb"Expected
"Hello"3
Input
"abc"Expected
"nop"4
Input
"The quick brown fox"Expected
"Gur dhvpx oebja sbk"5
Input
"123!"Expected
"123!"6
Input
""Expected
""Focus radio
Paused · SomaFM · Fluid