Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Creating a List | List
Python Data Structures

Creating a ListCreating a List

Data structures organize data based on its type. In Python, the primary data structures are lists, tuples, dictionaries, and sets, each with its distinct characteristics. In this course, we'll delve into these structures and discover how to utilize them effectively.

Python lists are ordered collections that can be changed and can hold items of any type. To make a list in Python, enclose the items within square brackets. Check out this example:

As demonstrated, a list can hold any combination of items, or even none at all. Consider the following example:

To initialize an empty list, simply assign empty square brackets to a variable.

A list can house items of any data type, be it a string or a number. Here's another example:

Time to practice.

Task

Craft your own list named list_1 with the following values:

1, 10, 'California', True

After crafting the list, hit the button underneath the code to verify your solution.

Everything was clear?

Section 1. Chapter 1
toggle bottom row
course content

Course Content

Python Data Structures

Creating a ListCreating a List

Data structures organize data based on its type. In Python, the primary data structures are lists, tuples, dictionaries, and sets, each with its distinct characteristics. In this course, we'll delve into these structures and discover how to utilize them effectively.

Python lists are ordered collections that can be changed and can hold items of any type. To make a list in Python, enclose the items within square brackets. Check out this example:

As demonstrated, a list can hold any combination of items, or even none at all. Consider the following example:

To initialize an empty list, simply assign empty square brackets to a variable.

A list can house items of any data type, be it a string or a number. Here's another example:

Time to practice.

Task

Craft your own list named list_1 with the following values:

1, 10, 'California', True

After crafting the list, hit the button underneath the code to verify your solution.

Everything was clear?

Section 1. Chapter 1
toggle bottom row
some-alt