list object python code example
Example 1: list in python
thislist = ["apple", "banana", "cherry"]
print(thislist[1])
Example 2: list in python
#list is data structure
#used to store different types of data at same place
list = ['this is str', 12, 12.2, True]
Example 3: 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))