tuple() Tuple constructor

Last updated: 2026-09-22

tuple() Tuple constructor

tuple() returns an immutable sequence; with no args returns () or an iterable's items as a tuple.

CategoryBuilt-in Functions
KindBuilt-in Function
Python Versionall

📝 Syntax

tuple([iterable])

⚙️ Parameters

iterable OptionalAn iterable; omitted gives ().(Default:None)

Returns:An immutable tuple of the iterable's items.

💥 Raises

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

('a', 'b', 'c')
(1, 2)
More case studies coming soon — check back later.

❓ FAQ

QWhat does tuple('abc') return?
AIt returns ('a', 'b', 'c') — converting each element of the iterable into a tuple.
QIs a tuple truly completely immutable?
AThe tuple itself is immutable (you cannot add, remove, reorder, or change elements), but if an element is a mutable object (e.g. a list) its content can still be modified, like t = ([1], 2); t[0].append(3) is legal.
QHow do I create a single-element tuple?
AUse a trailing comma: (1,) is a tuple, while (1) is just the integer 1; tuple([1]) also works.
QWhen should I choose tuple over list?
AUse a tuple when the data will not change and it must serve as a dict key or a set element (it is hashable); use a list when you need to add, remove, or modify elements.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏