Nested-loop
Nested-loop
shrinks). We can store all types of items (including another list) in a list. A
list may contain mixed type of items, this is possible because a list mainly
stores references at contiguous locations and actual items maybe stored at
different locations.
List can contain duplicate items.
List in Python are Mutable. Hence, we can modify, replace or delete the
items.
List are ordered. It maintain the order of elements based on how they are
added.
Accessing items in List can be done directly using their position (index),
starting from 0.
1.
a = [10, 20, 15]
print(a[0]) # access first itema.append(11) # add itema.remove(20) # remove item
print(a)
Creating a List
Here are some common methods to create a list: