Creation of both homogeneous and heterogeneous lists. : Introduction « List « Python Tutorial






numList = [2000, 2003, 2005, 2006]
stringList = ["Essential", "Python", "Code"]
mixedList = [1, 2, "three", 4]
subList = ["A", "B", ["C", 2006]]
listList = [numList, stringList, mixedList, subList]

for x in listList:
    for y in x:
        if isinstance(y, int):
            print y + 1
        if isinstance(y, basestring):
            print "String:" + y








7.1.Introduction
7.1.1.Defining a List
7.1.2.Creation of both homogeneous and heterogeneous lists.
7.1.3.Items of a list are separated by commas and enclosed in square brackets
7.1.4.Nested list
7.1.5.multidimensional arrays