String Repeater
Sometimes code needs to build a longer string from the same small piece, such as drawing a separator or repeating a pattern. Write a function repeat_str that takes a number repeat and a string string, then returns that string repeated the given number of times in a row. If repeat is 0, return an empty string.
Примеры
Ввод
3, "hello "Вывод
"hello hello hello "Ввод
2, "abc"Вывод
"abcabc"Ввод
0, "x"Вывод
""Нужно реализовать
def repeat_str(repeat: int, string: str) -> str:
Теги
strings
Sign in to see submission history
Sign inSign in to use AI Mentor
Sign inVisible tests
1
Input
3, "hello "Expected
"hello hello hello "2
Input
2, "abc"Expected
"abcabc"3
Input
0, "x"Expected
""4
Input
1, "single"Expected
"single"5
Input
5, "*"Expected
"*****"6
Input
2, "HELLO "Expected
"HELLO HELLO "Focus radio
Paused · SomaFM · Fluid