list of object in python code example
Example 1: how to call object of a list python
L = [1, 2, 3, 4]
print(L[1]) ## Calls the index position of the list "L"
Example 2: python list of objects
# Create a new class
class MyClass(object):
def __init__(self, number):
self.number = number
# Create a array to store your objects
my_objects = []
# Add 100 objects to array
for i in range(100):
my_objects.append(MyClass(i))