KnowledgeBoat Logo
|

Computer Science

What is nested tuple? Explain with example.

Python Tuples

3 Likes

Answer

A nested tuple is a tuple that contains other tuples as its elements. When we add one or more tuples inside another tuple, the items in the nested tuples are combined together to form a new tuple.

For example,

tuple1 = (0, 1, 2, 3)
tuple2 = ('python', 'book')
tuple3 = (tuple1, tuple2)
print(tuple3)
Output
((0, 1, 2, 3), ('python', 'book'))

Answered By

2 Likes


Related Questions