HomeSearch

Python List Methods

Store elements in a dynamically-sized list. Append to, remove from and loop over lists.
List. Time itself may be a list. Fossils tell us of great creatures that roamed millions of years ago. Antiquity leaves us with great mystery—but Python lists are easier to reason about.
List methods. Elements can be added, looped over or sorted. Lists can be combined with other structures. Each day adds another element to the list of time.[] (Initialize List)allanyappend (Add Element)del (Remove Element)extendfor (Loop Over List)filterin (Search List)index (Search List)insertlen (Get Element Count)list (List Built-in)mapmaxminreversereversedsortsortedsumzip[:] (Copy List)[* for * in list] (List Comprehension)[:*] (Resize List)
String list. We can place strings in a list, and then perform all operations upon the list. We also act directly up on the string elements.String List
Duplicates. Sometimes we want to remove duplicate elements from a list. If ordering is important, we may need a special method to avoid reordering elements. Here a set is useful.Duplicates
Two-dimensional. A list can contain other lists. We can use this kind of data structure as a two-dimensional grid of elements. These are jagged. Sub-lists can vary in length.2D List
Array. In Python a list is separate from an array. Lists are good for small data sets, but for larger amounts of data, arrays are far more efficient. They often use 90% less memory.Array
A summary. A list stores elements one after another, in a linear collection. In Python it handles any type of element, including numbers, strings—even tuples and other collections.
Home
Dot Net Perls
© 2007-2020 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.