Who Liked This

User interfaces often need to show who liked something in a clean sentence instead of dumping a raw list of names. Write likes, which takes a list names and returns the exact display text. The format changes depending on whether there are zero, one, two, three, or four-plus names.

Примеры

Ввод
[]
Вывод
"no one likes this"
Ввод
["Peter"]
Вывод
"Peter likes this"
Ввод
["Jacob", "Alex"]
Вывод
"Jacob and Alex like this"

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

def likes(names: list[str]) -> str:

Теги

stringslists
PostgreSQLv16

Här visas resultatet av din kod

Visible tests
1
Input
[]
Expected"no one likes this"
2
Input
["Peter"]
Expected"Peter likes this"
3
Input
["Jacob","Alex"]
Expected"Jacob and Alex like this"
4
Input
["Max","John","Mark"]
Expected"Max, John and Mark like this"
5
Input
["Alex","Jacob","Mark","Max"]
Expected"Alex, Jacob and 2 others like this"
6
Input
["PETER"]
Expected"PETER likes this"
Focus radio
Paused · SomaFM · Fluid