Repeat the Prefix
Sometimes you need to take a short prefix of a string and repeat it, for example to build a simple pattern or test string. Write a function front3 that takes a string s. Take the first 3 characters, or the whole string if it is shorter, and return that fragment repeated three times in a row.
Примеры
Ввод
"Java"Вывод
"JavJavJav"Ввод
"Chocolate"Вывод
"ChoChoCho"Ввод
"abc"Вывод
"abcabcabc"Нужно реализовать
def front3(s: str) -> str:
Теги
strings
Prijavite se za ogled zgodovine oddaj
PrijavaPrijavite se za uporabo mentorja UI
PrijavaVisible tests
1
Input
"Java"Expected
"JavJavJav"2
Input
"Chocolate"Expected
"ChoChoCho"3
Input
"abc"Expected
"abcabcabc"4
Input
"ab"Expected
"ababab"5
Input
""Expected
""6
Input
"Hello, World!"Expected
"HelHelHel"Focus radio
Paused · SomaFM · Fluid