Repeat the Front

Sometimes you need to take a short prefix of a string and repeat it several times, for example to build a pattern or a test string. Write a function front_times that takes a string s and a number n. Take the first 3 characters of the string, or the whole string if it is shorter, and repeat that fragment n times.

Примеры

Ввод
"Chocolate", 2
Вывод
"ChoCho"
Ввод
"Chocolate", 3
Вывод
"ChoChoCho"
Ввод
"Ab", 4
Вывод
"AbAbAbAb"

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

def front_times(s: str, n: int) -> str:

Теги

strings
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

Visible tests
1
Input
"Chocolate", 2
Expected"ChoCho"
2
Input
"Chocolate", 3
Expected"ChoChoCho"
3
Input
"Ab", 4
Expected"AbAbAbAb"
4
Input
"Ab", 0
Expected""
5
Input
"", 5
Expected""
6
Input
"Chocolate", -1
Expected""
Focus radio
Paused · SomaFM · Fluid