How to get element count in a tuple

Element count

len function returns the number of elements contained in a tuple.


inventory = ("a",
             "b",
             "c",
             "d")
#   w  ww. jav a 2 s . c om
print "You have", len(inventory), "items in your possession."

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary