Flip Letter Case
Sometimes you need to quickly flip the case of text: uppercase letters become lowercase, and lowercase letters become uppercase. Write a function toggle_case that takes a string s and returns a new string with the case of each letter changed. Characters that do not have case can stay unchanged.
Примеры
Ввод
"Hello"Вывод
"hELLO"Ввод
"abc"Вывод
"ABC"Ввод
"ABC"Вывод
"abc"Нужно реализовать
def toggle_case(s: str) -> str:
Теги
strings
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible tests
1
Input
"Hello"Expected
"hELLO"2
Input
"abc"Expected
"ABC"3
Input
"ABC"Expected
"abc"4
Input
"123"Expected
"123"5
Input
"PyThOn"Expected
"pYtHoN"6
Input
"HELLO"Expected
"hello"Focus radio
Paused · SomaFM · Fluid