Published in


10 Python One-Liners for Lists

Lists are one of the four built-in data structures (lists, tuples, sets and dictionaries) for holding a collection of objects in Python. Since we use lists so frequently, knowing a few one-liner code to work with lists can be greatly helpful. Here are ten of them which you may find yourself frequently using.

In all these examples, we will use the list cost=[23,24,26,29,41,29,35]

Note for adding or removing elements in a list, the one-liners that use the list methods and statements such as del directly changes the original list whereas external…



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Shen Ge

Hosts #Houston #spaceradio show #SG2onSpace and writes #shengecreative. Interested in #spaceflight #nasa #art #poetry #spaceflight