⊗pyPmLsECh 44 of 208 menu

Modifying List Elements in Python

List elements can be modified in the same way as string characters:

lst = [1, 2, 3] lst[0] = '!' print(lst) # ['!', 2, 3]

Given a list:

lst = [1, 2, 3, 4, 5]

Replace its second element with the number 10.

Given a list:

lst = ['a', 'b', 'c', 'd']

Replace the last element of the list with a boolean value.

The lists are given:

lst1 = [1, 2, 3] lst2 = ['a', 'b', 'c']

Replace the last element of the list lst1 with the last element of lst2. Print the first list to the console.

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