Grab the Middle

Sometimes you need to carefully extract the center of a string, like from a short code or word. Write get_middle, which returns the central part of the string s. If the length is odd, return one character; if it is even, return the two characters in the middle.

Примеры

Ввод
"test"
Вывод
"es"
Ввод
"testing"
Вывод
"t"
Ввод
"middle"
Вывод
"dd"

Нужно реализовать

def get_middle(s: str) -> str:

Теги

strings
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
"test"
Expected"es"
2
Input
"testing"
Expected"t"
3
Input
"middle"
Expected"dd"
4
Input
"A"
Expected"A"
5
Input
"of"
Expected"of"
6
Input
"ab"
Expected"ab"
Focus radio
Paused · SomaFM · Fluid