5Best

Example 1: Basic List Declaration

python
# Create a list with integers
my_list = [1, 2, 3, 4, 5]

Example 2: List Declaration with Strings

python
# Create a list with strings
my_list = ['apple', 'banana', 'cherry', 'orange', 'kiwi']

Example 3: List Declaration with Mixed Data Types

python
# Create a list with mixed data types
my_list = ['apple', 1, True, 3.14]

Example 4: List Declaration with Nested Lists

python
# Create a list with nested lists
my_list = [[1, 2, 3], ['apple', 'banana', 'cherry'], [True, False]]

Example 5: List Declaration Using List Comprehension

python
# Create a list using list comprehension
my_list = [i**2 for i in range(1, 6)]


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.