Multiplikation von Tupeln in Python
Man kann Tupel ebenfalls multiplizieren, d.h. sie
eine bestimmte Anzahl von Malen kopieren.
Dies geschieht mit dem Operator *:
tpl = ('a', 'b')
res = tpl * 2
print(res) # gibt ('a', 'b', 'a', 'b') aus
Gegeben ist das Tupel:
tpl1 = ('1', '2', '3')
Erstellen Sie daraus das folgende Tupel:
tpl2 = ('1', '2', '3', '1', '2', '3', '1', '2', '3')
Gegeben sind die Tupel:
tpl1 = ('a', 'b')
tpl2 = (1, 2)
Schreiben Sie Code, um das folgende Tupel zu erhalten:
tpl3 = ('a', 'b', 'a', 'b', 1, 2)