Function Details: tuple

Description


Returns a tuple whose items are the same and in the same order as iterable's items.


Extended Description


The tuple() function creates a tuple object. Tuples are immutable sequences, typically used to store collections of heterogeneous data. If no argument is given, it returns an empty tuple. If the argument is a sequence (string, list, or tuple), it returns a tuple with the same items in the same order. For any other iterable, it returns a tuple containing the items returned by repeatedly calling the iterable's __next__() method.


Read More about tuple from Python Documentation

Function Signature


tuple(iterable: Optional[Iterable] = None) -> tuple

Module: builtins

Class: tuple

Parameters



Parameter List


  • iterable: Optional[Iterable]

Return


Returns a tuple containing items from the given iterable.


Return Type


tuple

Output

Explanation

These examples show how tuple() works with different types of input.