Use Python’s * operator: text * count repeats a string the specified number of times. For example, "ha" * 3 produces "hahaha".
Repeat a string with the * operator
Python treats strings as sequences, so multiplying a string by a count repeats the entire string as a unit. The order of the operands can be reversed:
"ha" * 3 # "hahaha"
3 * "ha" # "hahaha"
"-" * 8 # "--------"
The Python 3.14.6 tutorial shows the same operation in 3 * 'un' + 'ium', which evaluates to 'unununium' (Python tutorial: An Informal Introduction to Python).
What happens with zero, negative, or non-integer counts?
- A count of zero produces an empty string:
"ha" * 0is"". - A negative count is treated as zero, so
"ha" * -2also produces"". - The count must be an integer or an object that implements the
__index__()method. A value that does not meet that requirement cannot be used as the repetition count.
These behaviors are specified in the Python 3.14.8 built-in types reference under sequence operations (Python built-in types documentation).
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
Put a separator between repeated copies
Multiplication joins copies directly together. To insert a separator, repeat the string in a sequence and call the separator’s join() method:
", ".join(["ha"] * 3) # "ha, ha, ha"
When to use join() or StringIO instead
For a fixed number of identical copies, multiplication is the straightforward choice. A different pattern arises when a loop builds one string incrementally from many pieces. Because strings are immutable, repeatedly concatenating pieces can have quadratic runtime cost as the result grows. The Python built-in types reference recommends collecting pieces and using str.join(), or writing incrementally with io.StringIO, to avoid that construction pattern.
Rank #2
String repetition is not a regular expression
To create repeated text, use an expression such as "a" * 3, which returns "aaa". A regular-expression quantifier such as a{3} describes a pattern that matches three a characters; it is not needed to build a string.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




