Mind Mapping the APPEND() method relative to other LIST methods (Post-003)


 Justin Sung's 12-steps of DEEP LEARNING

Indently's 11 LIST METHODS

list.CLEAR() <---> list.EXTEND(items) <--                                                     Append(one) 

Archer Newton -- The Mindmap Method: Learn Anything

Python what is a LIST?
Python has a great built-in list type named "list".
List literals are written within square brackets [ ].
Lists work similarly to strings
    -- use the len() function and square brackets [ ] to access data, with the first element at index 0.
(See the official 
python.org list docs.)

Here are some other common list methods.

  • list.append(elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original.
  • list.insert(index, elem) -- inserts the element at the given index, shifting elements to the right.
  • list.extend(list2) adds the elements in list2 to the end of the list. Using + or += on a list is similar to using extend().
  • list.index(elem) -- searches for the given element from the start of the list and returns its index. Throws a ValueError if the element does not appear (use "in" to check without a ValueError).
  • list.remove(elem) -- searches for the first instance of the given element and removes it (throws ValueError if not present)
  • list.sort() -- sorts the list in place (does not return it). (The sorted() function shown later is preferred.)
  • list.reverse() -- reverses the list in place (does not return it)
  • list.pop(index) -- removes and returns the element at the given index. Returns the rightmost element if index is omitted (roughly the opposite of append()).

Notice that these are *methods* on a list object, while len() is a function that takes the list (or string or whatever) as an argument.

MORE TO EXPLORE
Magnetic Memory -- 6 Hidden Mind Map Benefits For Better Memory, Creativity


Comments

Popular posts from this blog

Back Stage Support for Old Man Learns to Code (Post-001)

Learn Lists and Modules --FRAME (000)