Jason S Jason S - 1 year ago 97
Python Question

How to repeat individual characters in strings in Python

I know that

"123abc" * 2

evaluates as
, but is there an easy way to repeat individual letters N times, e.g. convert

Answer Source

What about:

>>> s = '123abc'
>>> n = 3
>>> ''.join(char*n for char in s)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download