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.

Click to rate this post!
[Total: 5 Average: 1]
Please follow and like us:

3 Comments

  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 *