How to print a string two times with single statement in Python?

PythonServer Side ProgrammingProgramming

When used with strings, asterisk (*) is defined as repetition operator. It concatenates given string as many times as number followed by asterisk.

>>> string = 'abcdefghij'
>>> print (string*2)
   abcdefghijabcdefghij
raja
Published on 29-Dec-2017 05:51:09
Advertisements