Python Tuple With One Item
Python Glossary
Create Tuple With One Item
To create a tuple with only one item, you have add a comma after the item, unless Python will not recognize the variable as a tuple.
Example
One item tuple, remember the commma:
thistuple = ["apple",]
print[type[thistuple]]
#NOT a tuple
thistuple = ["apple"]
print[type[thistuple]]
Try it Yourself »
print[type[thistuple]]
#NOT a tuple
thistuple = ["apple"]
print[type[thistuple]]
Related Pages
Python Tuples Tutorial Tuple Access Tuple Items Change Tuple Item Loop List Items Check if Tuple Item Exists Tuple Length Remove Tuple Items Join Two Tuples
Python Glossary