How to do string concatenation without '+' operator in Python?

PythonServer Side ProgrammingProgramming

You can use str.join(list_of_strings) from the string class. The string you call it on is used to join the list of strings you provide as argument to it.

For example

>>> ' '.join(['Hello', 'World'])
'Hello World'
>>> ''.join(['Hello', 'World', 'People'])
>>> ', '.join(['Hello', 'World', 'People'])
'Hello, World, People'

Note that the string we call it on is inserted in between the list of strings we pass it as argument.

Published on 18-Dec-2017 08:50:25