Concatenation of strings in Python
To add (concatenate) strings, use the operator +:
test = 'abc' + 'def' # add two lines
print(test) # 'abcdef'
Strings can also be stored in variables:
test1 = 'abc'
test2 = 'def'
test3 = test1 + test2 # add two lines
print(test3) # 'abcdef'
You can also add variables and strings:
test1 = 'abc'
test2 = 'def'
test3 = test1 + '!!!' + test2
print(test3)
Two lines are given:
txt1 = 'abc'
txt2 = 'def'
Merge these lines into one new one and display it on the screen.
The following lines are given:
txt1 = '12'
txt2 = '+'
txt3 = '5'
txt4 = '17'
Merge these lines into one new one and display it on the screen.
Change the solution to the previous problem so that after the merge, between the third and fourth lines there is an operator =.