- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is correct syntax to create Python tuples?
In Python, tuple object is an immutable collection of items, not necessarily of same type. Items are separated by comma and placed inside parentheses, although they are optional.
>>> T1 = (1,'one',3.45,[1,2,3]) >>> T2 = 1,2,3,4
Empty tuple object is created with nothing inside parentheses
>>> T3 = () >>> T3 ()
If only one item is to be included in a tuple, an additional comma is placed after it.
>>> T4 = 10, >>> T4 = (5,)
Advertisements