In this article, we are going to revisit CodeWars and solve a simple problem using Python. The problem is as follows.

Write a Python function that will repeat the given string with the number of times that string supposed to be repeated. The solution to this question is as follows.

def repeat_str(repeat, string):
    repeatString = ''
    for i in range(0, repeat):
        repeatString += string
    return repeatString

As you can see from above, the repeated string will be returned to the caller of this function.

Please follow and like us:


  1. Am I missing something completely or is there an even simpler solution?

    def repeat_str(repeat, string):
    return string * repeat

Leave a Reply

Your email address will not be published. Required fields are marked *