Tupel Vermenigvuldiging in Python
Ons kan ook tuplis vermenigvuldig, dit wil sê, 'n sekere aantal kere kopieer.
Dit word gedoen met behulp van die *-operator:
tpl = ('a', 'b')
res = tpl * 2
print(res) # sal ('a', 'b', 'a', 'b') uitdruk
Gegewe tupel:
tpl1 = ('1', '2', '3')
Skep die volgende tupel daaruit:
tpl2 = ('1', '2', '3', '1', '2', '3', '1', '2', '3')
Gegewe tuplis:
tpl1 = ('a', 'b')
tpl2 = (1, 2)
Skryf kode om die volgende tupel te kry:
tpl3 = ('a', 'b', 'a', 'b', 1, 2)