Pack Text into Pairs

This is like packing text into small blocks of two characters each. Write split_pairs, which splits the string s into pairs and returns them as a list. If the final character has no partner, add _ to complete the pair; if s is empty, return an empty list.

Примеры

Ввод
"abc"
Вывод
["ab", "c_"]
Ввод
"abcdef"
Вывод
["ab", "cd", "ef"]
Ввод
""
Вывод
[]

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

def split_pairs(s: str) -> list[str]:

Теги

stringslists
PostgreSQLv16

Šeit parādīsies koda izpildes rezultāts

Visible tests
1
Input
"abc"
Expected["ab","c_"]
2
Input
"abcdef"
Expected["ab","cd","ef"]
3
Input
""
Expected[]
4
Input
"a"
Expected["a_"]
5
Input
"abcde"
Expected["ab","cd","e_"]
6
Input
"ab"
Expected["ab"]
Focus radio
Paused · SomaFM · Fluid