Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Tuple Literal Values

A tuple is created by surrounding objects with ()'s and separating the items with commas (,). An empty tuple is empty ()'s. An interesting question is how Python tells an expression from a 1-tuple. A 1-element tuple has a single comma: (1,). An expression lacks the comma: (1). A pleasant consequence of this is that an extra comma at the end of every tuple is legal; for example, (9, 10, 56, ).


xy= (2, 3)
personal= ('Hannah',14,5*12+6)
singleton= ("hello",)

The elements of a tuple do not have to be the same type. A tuple can be a mixture of any Python data types, including other tuples.

  Published under the terms of the Open Publication License Design by Interspire