Flip the Text
Reversing a string is a simple but useful way to practice working with characters and positions. Write a function reverse_string that takes a string s and returns it in reverse order. An empty string should stay empty, and a one-character string should stay unchanged.
Примеры
Ввод
"hello"Вывод
"olleh"Ввод
""Вывод
""Ввод
"a"Вывод
"a"Нужно реализовать
def reverse_string(s: str) -> str:
Теги
stringstwo-pointers
Влез, за да видиш историята на решенията
ВходВлез, за да използваш ИИ ментора
ВходVisible tests
1
Input
"hello"Expected
"olleh"2
Input
""Expected
""3
Input
"a"Expected
"a"4
Input
"Python"Expected
"nohtyP"5
Input
"12345"Expected
"54321"6
Input
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Expected
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"Focus radio
Paused · SomaFM · Fluid