⊗pyPmTpTC 69 of 208 menu

Concatenating Tuples in Python

To combine tuples, you can use the + operator:

tpl1 = ('a', 'b', 'c') tpl2 = ('d', 'e') res = tpl1 + tpl2 print(res) # ('a', 'b', 'c', 'd', 'e')

Three tuples are given:

tpl1 = ('1', '2', '3') tpl2 = ('4', '5', '6') tpl3 = ('7', '8', '9')

Merge the elements of these tuples into a single new tuple.

The following tuples are given:

tpl1 = (3, 4) tpl2 = (1, 2)

Merge them to get the following tuple:

tpl3 = (1, 2, 3, 4)
byenru