Creating a histogram from a list of values. : Length « List « Python Tutorial






values = []   # a list of values

print "Enter 10 integers:"

for i in range( 10 ):
   newValue = int( raw_input( "Enter integer %d: " % ( i + 1 ) ) )
   values += [ newValue ]

print "\nCreating a histogram from values:"
print "%s %10s %10s" % ( "Element", "Value", "Histogram" )

for i in range( len( values ) ):
   print "%7d %10d  %s" % ( i, values[ i ], "*" * values[ i ] )








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.