Saamvoeging van Tupels in Python

Om tupels saam te voeg, kan die operateur + gebruik word:

pythontpl1 = ('a', 'b', 'c')
tpl2 = ('d', 'e')

res = tpl1 + tpl2
print(res) # sal ('a', 'b', 'c', 'd', 'e') uitdruk
Задание 1

Gegee drie tupels:

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

Voeg die elemente van hierdie tupels saam in een nuwe tupel.

Задание 2

Gegee tupels:

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

Voeg hulle saam om die volgende tupel te kry:

pythontpl3 = (1, 2, 3, 4)