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