concatenation:
- In python, concatenation is defined as "the process of combining or joining or merging one string with the other string".
- It uses the plus operator for combining the strings.
- The string must be enclosed with single quotations or double.
- Type conversion is needed.
- We can combine an integer value with a string by using the str(int) function.
- The plus(+) operator is used to combine the string at the end of the string.
- The % string format operator is used to combine the string anywhere we want.
#write a python program to demonstrate concatenation function.
- a="python"
- b="programming"
- x=a+b
- print(x)
- str1="python"
- str2=str(3.0)
- str=str1+str2
- print(str)
Output: pythonprogramming
python3.0
No comments