aList = [] # create empty list
for number in range( 1, 11 ):
aList += [ number ]
print "The value of aList is:", aList
print "\nAccessing values by iteration:"
for item in aList:
print item,
print
print "Subscript Value"
for i in range( len( aList ) ):
print "%9d %7d" % ( i, aList[ i ] )
print "\nModifying a list value..."
print "Value of aList before modification:", aList
aList[ 0 ] = -100
aList[ -3 ] = 19
print "Value of aList after modification:", aList
|