⊗pyPmTpMl 70 of 208 menu

Multiplying Tuples in Python

We can also multiply tuples, i.e. copy them a certain number of times. This is done using the operator *:

tpl = ('a', 'b') res = tpl * 2 print(res) # ('a', 'b', 'a', 'b')

A tuple is given:

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

Create the following tuple from it:

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

The following tuples are given:

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

Write code to get the following tuple:

tpl3 = ('a', 'b', 'a', 'b', 1, 2)
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline