#
File Lists06.py
# Rev 2/4/00 # Copyright 2000, R. G. Baldwin # Illustrates extracting a # list element and extracting # elements from a nested list # #------------------------------- print "Create and print a list" listA = [100,200,300,400,500] print listA print "Original length is:" print len(listA) print "Replace an element" listA[2] = [2,4,8,16,32,64] print "Print the modified list" print listA print "Modified length is:" print len(listA) print "Extract and display each" print " element in the list" print listA[0] print listA[1] print listA[2] print listA[3] print listA[4] print "Extract and display
each"
Figure 5 |