Built-in Functions and Types
tuple()
Create an immutable sequence from an iterable. A tuple cannot have its slots reassigned, but contained mutable objects can still change. A tuple is hashable only when every member is hashable. An existing exact tuple may be returned unchanged. The comma, not parentheses alone, forms a one-item tuple literal.
Formal Syntax & Structure
python syntaxpython
tuple(iterable=(), /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| iterable | iterable | Items to collect; defaults to an empty sequence. |
Return Value
tuple
Ordered immutable sequence of the supplied objects.
Working Example
Example Snippetpython
coordinates = tuple([4, 9])print(coordinates)print(tuple("AB"))print((5,))