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
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

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