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_listwith any 3 elements.
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules