Edges of Text

Slices make it easy to build a new string from different parts of an old one. Write a function first_two_last_two that takes a string s and returns its first two characters followed by its last two characters. If the string has length less than 2, return an empty string.

Примеры

Ввод
"w3resource"
Вывод
"w3ce"
Ввод
"w3"
Вывод
"w3w3"
Ввод
"w"
Вывод
""

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

def first_two_last_two(s: str) -> str:

Теги

strings
PostgreSQLv16

Hawn jidher ir-riżultat tat-tħaddim tal-kodiċi

Visible tests
1
Input
"w3resource"
Expected"w3ce"
2
Input
"w3"
Expected"w3w3"
3
Input
"w"
Expected""
4
Input
""
Expected""
5
Input
"abcd"
Expected"abcd"
6
Input
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Expected"xxxx"
Focus radio
Paused · SomaFM · Fluid