out[ ] list in contrast with tupleslists are variable-length and their contents can be modified they can be defined using square brackets [or using the list type functionin [ ]a_list [ nonein [ ]tup ('foo''bar''baz'in [ ]b_list list(tupin [ ]b_list out[ ]['foo''bar''baz'in [ ]b_list[ 'peekabooin [ ]b_list out[ ]['foo''peekaboo''baz'lists and tuples are semantically similar as one-dimensional sequences of objects and thus can be used interchangeably in many functions adding and removing elements elements can be appended to the end of the list with the append methodin [ ]b_list append('dwarf'in [ ]b_list out[ ]['foo''peekaboo''baz''dwarf'using insert you can insert an element at specific location in the listin [ ]b_list insert( 'red'in [ ]b_list out[ ]['foo''red''peekaboo''baz''dwarf'insert is computationally expensive compared with append as references to subsequent elements have to be shifted internally to make room for the new element the inverse operation to insert is popwhich removes and returns an element at particular indexin [ ]b_list pop( out[ ]'peekabooin [ ]b_list out[ ]['foo''red''baz''dwarf'elements can be removed by value using removewhich locates the first such value and removes it from the last appendixpython language essentials www it-ebooks info