⊗pyPmLsLE 43 of 208 menu

Last element of a list in Python

The last element of a list can be obtained in the same way as the last character of a string:

lst = [1, 2, 3, 4] print(lst[-1]) # 4

Let the following list be given:

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

Display the last item in this list.

Modify the previous task to print the second to last item in the list.

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