How to concatenate strings in python?

In Python, there are multiple ways to concatenate strings.


  hello = 'Hello'
  world = 'World'
  message = hello + ' ' + world


Using the + operator is a common method, but you can also use the format() function or f-strings in Python 3.6+.

  message = '{} {}'.format(hello, world)
  # Or using f-string
  message = f'{hello} {world}'

Beginner's Guide to Python