⊗pyPmLsLA 49 of 208 menu

Appending to a List in Python

We can also combine two lists, changing the original one. In such cases, we use the operator +=:

lst1 = [1, 2, 3] lst2 = [4, 5, 6] lst1 += lst2 print(lst1) # [1, 2, 3, 4, 5, 6]

Two lists are given:

lst1 = ['12', '34', '56'] lst2 = ['ab', 'cd', 'ef']

Combine them.

Two lists are given:

lst1 = ['a', 'b', 'c'] lst2 = [4, 5, 6]

Add the first list to the second.

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