In Python, we can add two strings. The process of combining two strings is called concatenation. Two strings, whether created using single or double quotes, are concatenated in the same way.
Python Concatenation Examples
a="Apple is Red." b="Apple is also Green." c=a+b print(c)
Apple is Red.Apple is also Green.
We can also add numbers as a string. However, adding a string to a number generates an error.
a="Pyton" b=3.4 c=a+b print(c)
Here we are concatenating a string and a number; an error is generating.
a="12" b="34" c=a+b print(c)
Here the above program concatenates two numbers that are represented as strings.
Leave a comment