In Python, a list is an dynamic ordered collection of items of any type.
Dynamic means that the size of the list can be changed by adding or
removing items.
If you already know about arrays you know that an array is an ordered
collection of items of the same type. Arrays are sometimes also dynamic but
not always.
myList = []
myList.append(4)
myList.append(7)
myList.append(1)
myList.append(3)
myList.append(9)
myList=[1,2,3,4,5,6]
myList
len(myList)
myList[1] - one element
myList[2] - one element
myList[:3] - range of elements 0, 1 and 2
myList[2:] - range of elements 2 and further to the end of the list
def reverse_list(x):
return x[::-1]
List searching
http://www.effbot.org/zone/python-list.htm#searching
if value in L:
print "The list contains", value
i = L.index(value)