Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    Repeat String in Python

    Python Programming Tutorials


    Sometimes we need to repeat the string in the program, and we can do this easily by using the repetition operator in Python.

    The repetition operator is denoted by a '*' symbol and is useful for repeating strings to a certain length.

    Example:

    str = 'Python program'
    print(str*3)

    The above lines of code will display the following outputs:

    Python programPython programPython program

    Similarly, it is also possible to repeat any part of the string by slicing:

    Example:

    str = 'Python program'
    print(str[7:9]*3) #Repeats the seventh and eighth character three times
    prprpr


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.