Combine Strings in Python

  • Post category:String

In Python, you can use the + operator to combine strings. In the below code, we will combine two strings.

Step 1: Create a string

str1 = "Code"
str2 = "Allow"
print("str1 = ", str1)
print("str1 type = ", type(str1))
print("str2 = ", str2)
print("str2 type = ", type(str2))

Step 2: Combine string

print("str = ", str1 + str2)

Output:

str1 =  Code
str1 type =  <class 'str'>
str2 =  Allow
str2 type =  <class 'str'>
str =  CodeAllow

Free resources to learn advanced skills: AiHints and CodeAllow