Repeat a string for a specified number of times

Input

  • text [str]
  • times [int]

Output

  • repeat [str]

Endpoint

https://hub.xpub.nl/soupboat/si16/api/repeat/ ? text=<text> & times=<times>

Try it



Repeat

Repeat a string for a specified number of times

def repeat(text: str, times: int = 2) -> str:
    """Repeat a string for a specified number of times"""
    return text * times

ara repeating itself

This function has many attractive qualities, but its ability to repeat human speech is one that makes it truly unique among other types of companion python functions and one that has ensured its popularity for generations. You are likely to find, though, that the function's talents for mimicry still pales in comparison to the fact that it is charming, engaging, and truly remarkable. Here is one of the most popular repeating function so that you can appreciate more about what it has to offer. It often says injuries to people and computers.

Examples

The function takes a string as a parameter, and by default it repeats it twice.

repeat('hello')
'hellohello'

Eventually with a second parameter you can specify how many times you want it to repeats.

repeat('salut', 4)
'salutsalutsalutsalut'