The collection is nothing but a group of items.

There are 4 collection data types in Python and they are,

  1. List
  2. Tuple
  3. Set
  4. Dictionary

List

A list is a collection that is ordered and changeable. Lists are written using square brackets([]).

Syntax:

list_variable = [list values in double-quotes separated with comma operator]

Example:

Image for post

Access items from List:

We can access the items of the List using the index.

For example, if you want to print the second item of the List, we can do in the following way,

Image for post

Output:

Image for post

#collection #lists #python #advanced

Python Collections - Part 1
2.00 GEEK