Google News
logo
Python Program to Create a List
In Python, you can create a list using square brackets `[]`. Here's an example program :
Program :
# create a list of numbers
numbers = [1, 2, 3, 4, 5]

# print the list
print(numbers)

In this program, a list of numbers is created using square brackets, and assigned to the variable `numbers`. The `print()` function is then used to print the list to the console. The output of this program will be :

Output :
[1, 2, 3, 4, 5]
You can create a list of any type of data in Python, including strings, integers, and even other lists. Here's an example program that creates a list of strings :
Program :
# create a list of strings
fruits = ['apple', 'banana', 'cherry', 'orange']

# print the list
print(fruits)
Output :
['apple', 'banana', 'cherry', 'orange']
In this program, a list of strings is created using square brackets, and assigned to the variable `fruits`. The `print()` function is then used to print the list to the console.