Združevanje n-teric v Pythonu
Za združevanje n-teric lahko uporabimo
operator +:
tpl1 = ('a', 'b', 'c')
tpl2 = ('d', 'e')
res = tpl1 + tpl2
print(res) # izpiše ('a', 'b', 'c', 'd', 'e')
Podane so tri n-terice:
tpl1 = ('1', '2', '3')
tpl2 = ('4', '5', '6')
tpl3 = ('7', '8', '9')
Združite elemente teh n-teric v eno novo n-terico.
Podane so n-terice:
tpl1 = (3, 4)
tpl2 = (1, 2)
Združite jih tako, da boste dobili naslednjo n-terico:
tpl3 = (1, 2, 3, 4)