Multiplisering av tupler i Python

Vi kan også multiplisere tupler, dvs. kopiere dem et visst antall ganger. Dette gjøres ved hjelp av operatoren *:

pythontpl = ('a', 'b')
res = tpl * 2

print(res) # vil skrive ut ('a', 'b', 'a', 'b')
Задание 1

Gitt tuplen:

pythontpl1 = ('1', '2', '3')

Lag følgende tuple fra den:

pythontpl2 = ('1', '2', '3', '1', '2', '3', '1', '2', '3')
Задание 2

Gitte tupler:

pythontpl1 = ('a', 'b')
tpl2 = (1, 2)

Skriv kode for å få følgende tuple:

pythontpl3 = ('a', 'b', 'a', 'b', 1, 2)