OKPEDIA PYTHON EN

How to concatenate strings in Python

To concatenate two strings in python use the operator +.

string1 + string2

The second string (string2) is added after the last character of the first string (string1).

Example

Combine two alphanumeric variables and a string constant (space).

first_name = "Adam"
last_name = "Smith"
full_name = first_name + ' ' + last_name
print(full_name)

The full_name string consists of the first string, a space character, and the second string.

The output result is the following:

Adam Smith

https://how.okpedia.org/en/python/how-to-concatenate-strings-in-python


Report an error or share a suggestion to enhance this page



FacebookTwitterLinkedinLinkedin