On Python Terminal:
>>> l = [1, 3, 2, 4]
>>> dir(l)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> l.sort()
>>> l
[1, 2, 3, 4] # sorted list
dir - will return a list attributes and methods present in that object.
To sort a list we can use, sort method.
Append - append a new element to list:
>>> l.append(2)
>>> l
[1, 2, 3, 4, 2]
>>> l.append(2)
>>> l
[1, 2, 3, 4, 2, 2]
Count - returns no of occurrences of an element
>>> l.count(2)
3
So, we can conclude here that duplicate elements can be present a list.
Reverse - To reverse elements in a list
>>> l
[1, 2, 3, 4, 2, 2]
>>> l.reverse()
>>> l
[2, 2, 4, 3, 2, 1]
Index - To find the position of the element in list ( Note: Indexing will start from 0)
>>> l.index(1) # Index starts from 0, So 1 positioned at 5th place in above list "l"
5
>>> l.index(4)
2
>>> l.index(2) #Gives the index of first occurrence of element in a list.
0
Wanna find index from some other starting point, we can mention it in index method
>>> l = [2, 2, 4, 3, 2, 1]
>>> l.index(2, 1) # Find index from 2nd position (Since indexing will start from 0, here 1 is to be considered as 2nd position)
1
>>> l.index(2, 2)
4
Remove - To remove an element from a list
>>> l.remove(1) # 1 is removed from the list
>>> l
[2, 2, 4, 3, 2]
>>> l.remove(2) # first occurred element of 2 is removed. But not all ( Remember it.... )
>>> l
[2, 4, 3, 2]
Extend - to extend the present list with other list ( Note: Append and Extend are different. See difference below.)
>>> l.extend([9,8,7]) #Extends the list "l" with new list [9,8,7]
>>> l
[2, 4, 3, 2, 9, 8, 7]
>>> l.append([9,8,7]) # Append will consider list [9,8,7] as an element and it will append it to "l"
>>> l
[2, 4, 3, 2, 9, 8, 7, [9, 8, 7]]
Pop - this function will pop out the last element in list.
>>> l
[2, 4, 3, 2, 9, 8, 7, [9, 8, 7]]
>>> l.pop()
[9, 8, 7]
>>> l
[2, 4, 3, 2, 9, 8, 7]