Sammanfogning av tuplar i Python

För att sammanfoga tuplar kan du använda operatorn +:

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

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

Givna är tre tuplar:

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

Slå ihop elementen från dessa tuplar till en ny tupel.

Задание 2

Givna tuplar:

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

Slå ihop dem så att du får följande tupel:

pythontpl3 = (1, 2, 3, 4)