Python Repeat String N Times: A Beginner Example – Python Tutorial

By | July 28, 2020

It is very easy to repeat a python string in python. In this tutorial, we will use an example to illustrate python beginners how to do.

Create a python string

text = 'tutorialexample'

Repeat it 3 times

We can use * operation to repeat a python string.

texts = text * 3

Then you will find the texts will be:


Moreover, if you want to use a character to split the repeated string, you can do like this.

Save string to a python list


l = []

List l will save text.

Repeat list n time

texts = l * 3

texts will be:

['tutorialexample', 'tutorialexample', 'tutorialexample']

Join all elements in list


Then you will get the result:


From this code above, we can find we also can use * to repeat python list.

Leave a Reply

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