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
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible 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