PYTHON COMMON LIST METHODS
The Python List type contains various methods that can be used to interface with list collections. Below is a list of some of these methods.
Ex.
myList = [“Red”, “Green”, “Blue”]
len()
Returns the length of the string. (Not exclusive to string types.
IN: len(myList)
OUT: 3
myList.append()
Adds an item to the end of the list.
IN: myList.append(“Purple”)
OUT: [“Red”, “Green”, “Blue”, “Purple”]
myList.reverse()
Reverses the elements in the list
IN: myList.reverse()
OUT: [“Blue”, “Green”, “Red”]
myList.remove(y)
Removes the first item from the list whose value is y.
IN: myList.remove(“Blue”)
OUT: [“Red”, “Green”
For a complete listing of Python List methods, visit: https://docs.python.org/2/tutorial/datastructures.html