next up previous contents
Next: Indexing and Slicing Up: String Operations Previous: Concatenation   Contents


The asterisk (*), when used between a string and an integer creates a new string with the old string repeated by the value of the integer. The order of the arguments is not important. So the following two statements will both print ten dashes:
>>> '-' * 10
>>> 10 * '-'
Trying to use the repetition operator between two strings results in a Type Error exception.

Phil Spector 2003-11-12