python set list size code example
Example 1: python initialize list length n
Creating an empty list:
>>> l = [None] * 10
>>> l
[None, None, None, None, None, None, None, None, None, None]
Example 2: create a list of a certain length python
>>> l = range(10)
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Example 3: how to get size of list in python
list_1 = ["Hello", 1, "World", 2]
print(len(list_1))
import sys
print(sys.getsizeof(list_1), "Bytes")
Example 4: python list of size
li = [None] * 5
li = [0] * 5