A tuple with one item: a comma : Tuple Length « Tuple « Python






A tuple with one item: a comma

A tuple with one item: a comma

# A tuple with one item is constructed by following a value with a comma 
# (it is not sufficient to enclose a single value in parentheses). 
# Ugly, but effective. For example:

singleton = 'hello',    # <-- note trailing comma

print len(singleton)

print singleton

           
       








Related examples in the same category

1.Get the length of a tupleGet the length of a tuple