Creating, accessing and changing a list. : Length « List « Python Tutorial






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








7.14.Length
7.14.1.Get the length of a list
7.14.2.len() provides the total number of elements in the tuple .
7.14.3.Creating, accessing and changing a list.
7.14.4.Creating a histogram from a list of values.