How to create a list in Python
![](https://pythonpoint.net/wp-content/uploads/2020/11/How-to-create-a-list-in-Python-1024x576.jpg)
In Python, lists can be made by placing elements inside a square bracket[]. List doesn’t need a built-in function for creation.
list1 = [] print(list1) list2 = [2, 3, 1, 4] print(list2)
output:
[] [2, 3, 1, 4]
A list in Python can contain different type of data.
l1 = [1, 'Python', 3, 'Hello'] print (l1)
Output:
[1, 'Python', 3, 'Hello']
Subscribe
Login
Please login to comment
0 Discussion