In any programming language, it is often required to merge or combine strings together. This process is called concatenation. In Python, there are multiple ways to concatenate strings. Here are some examples.
# Concatenate strings using + operator. firstname = 'Nikki' lastname = 'Brown' fullname = firstname + " " + lastname print( fullname ) # Add strings together using string formatter: {} is the placeholder. fullname = "{} {}".format(firstname, lastname) print( fullname ) # Concatenate strings using join() function. tmp_list = [firstname, lastname] print( ' '.join(tmp_list) )
Output
Nikki Brown Nikki Brown Nikki Brown