Python list object is a general sequence.
Lists are position-ordered collections of arbitrarily typed objects.
Lists have no fixed size and they are mutable.
Lists can be modified in place by assignment to offsets as well as a variety of list method calls.
Because lists are sequences, lists support all the sequence operations.
For instance, given a three-item list:
L = [123, 'test', 1.23] # A list of three different-type objects print( len(L) ) # Number of items in the list
We can index, slice, and so on, just as for strings:
L = [123, 'test', 1.23] # A list of three different-type objects print( L ) # Indexing by position print( L[:-1] ) # Slicing a list returns a new list print( L + [4, 5, 6] ) # Concat/repeat make new lists too print( L * 2 ) print( L ) # We're not changing the original list # w ww . jav a2s . c o m