Python List

List In Python

What is list?

Python lists are container used to store collection of different data types in a single variable. It is always enclosed with square-bracket.


You can also change other data types into list.


List Properties

Following are the properties of list :

  • Ordered : List items have a fixed order that can not be changed.
  • Changeable : List items can be changed, means elements can be added or removed from the list.

  • Allow Duplicate : List items can be used multiple times in the same list.
  • Indexed : List elements can be sliced or indexed "list indexing or list slicing", just like string slicing. shown below,

List Methods

Python list methods helps to manipulate the lists. Following are built-in list methods :

  •  list.append()  : Used to add an element at the end of the given list.

  •  list.extend()  : Used to add string elements at the end of the list.
  •  list.insert()  : Used to add a element at the specific position.


  •  list.remove()  : Use to remove a element.
  •  list.pop()  : Used to remove a element from the specific position.
  •  list.clear()  : Used to remove all the element from the list.


  •  list.count()  : Used to count the number of a specific element.

  •  list.index()  : Used to find the index of a specific element.
  •  list.copy()  : Used to copy a list.

  • list.reverse()  : Used to reverse the order of the list.
  • list.sort()  : Used to arrange the list elements into ascending order.


Tell me list of fruits in comment section using python lists.

Comments