Kortežu apvienošana Python
Lai apvienotu kortežus, var izmantot
operatoru +:
tpl1 = ('a', 'b', 'c')
tpl2 = ('d', 'e')
res = tpl1 + tpl2
print(res) # izvadīs ('a', 'b', 'c', 'd', 'e')
Doti trīs korteži:
tpl1 = ('1', '2', '3')
tpl2 = ('4', '5', '6')
tpl3 = ('7', '8', '9')
Apvienojiet šo kortežu elementus vienā jaunā kortežā.
Doti korteži:
tpl1 = (3, 4)
tpl2 = (1, 2)
Apvienojiet tos tā, lai iegūtu šādu kortežu:
tpl3 = (1, 2, 3, 4)