How to concatenate two strings in python?

In Python programming concatenate two strings is very easy. Strings can be concatenated  with the + operator, and repeated with * operator. Examples are given below.

>>># We can see in below example how concatenate two strings using  + operator

>>> ‘Gyan’ + ‘today’

‘Gyantoday’

>>># We can see in below example how repeat strings using  * operator

>>> 3*’Go’+’Goa’

‘GoGoGoGoa’

Also we can concatenate variables and a string literals.

>>> pre = ‘Gyan’
>>> pre + ‘today’
‘Gyantoday’

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.