Shorter String
Comparing string lengths is useful when choosing a shorter name, code, or label. Write a function min_cat that takes two strings a and b. Return the string with fewer characters. If both strings have the same length, return the first string a.
Примеры
Ввод
"hello", "hi"Вывод
"hi"Ввод
"ab", "cd"Вывод
"ab"Ввод
"x", "yyy"Вывод
"x"Нужно реализовать
def min_cat(a: str, b: str) -> str:
Теги
strings
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
"hello", "hi"Expected
"hi"2
Input
"ab", "cd"Expected
"ab"3
Input
"x", "yyy"Expected
"x"4
Input
"", "abc"Expected
""5
Input
"x", " "Expected
"x"6
Input
"", "cba"Expected
""Focus radio
Paused · SomaFM · Fluid