Skip to content

Python concatenate variables

  • by

You can concatenate variables using the + operator (combine two or more strings) in Python. The + operator should appear between the two variables you want to merge.

Python concatenate variables

Simple example code.

a = 'lemon'
b = 'lime'
soda = a + b

print("concatenate variables", soda)


Python concatenate variables

Concatenate strings and variables in Python

my_list = ['a', 'b', 'c', 'd']
my_string = ','.join(my_list)


Output: a,b,c,d

Do comment if you have any doubts or suggestions on this Python concatenate topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *