Editor settings

General settings

Save settings

Learn to program with Python

Lists in Python #

In Python, a list is a data structure that is used to store a collection of items of any data type. Lists are created using square brackets [] and each element is separated by a comma ,.

Here is an example of creating a list with five integer elements.:

my_list = [1, 2, 3, 4, 5]

We can also create a list with elements of different data types. In this example, we have a list with elements of string, float, boolean:

my_list = ['apple', 3.14, True]

Example #

  • Create a variable named my_list with any 3 elements.
Output will be displayed here