Tuples are store multiple items in a single variable in Python. A tuple is an immutable object meaning that we cannot change, add or remove items after the tuple has been created.
empty_tuple = ()
mytuple = ("apple", "banana", "cherry")
How to create and use tuple in Python
Simple example code creating non-empty tuples. Tuples that are ordered will not change, unchangeable and Allow Duplicates.
# One way of creation tup = 'A', 'B' print(tup) # Another for doing the same tup = ('X', 'Y') print(tup)
Do comment if you have any doubts and suggestions on this Python tuple basics tutorial.
Note: IDE: PyCharm 2021.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.