Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Tuple Operations in Python
Next article icon

Python Tuples

Last Updated : 04 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

A tuple in Python is an immutable ordered collection of elements. Tuples are similar to lists, but unlike lists, they cannot be changed after their creation (i.e., they are immutable). Tuples can hold elements of different data types. The main characteristics of tuples are being ordered , heterogeneous and immutable.

Creating a Tuple

A tuple is created by placing all the items inside parentheses (), separated by commas. A tuple can have any number of items and they can be of different data types.

Example:

Python
tup = () print(tup)  # Using String tup = ('Geeks', 'For') print(tup)  # Using List li = [1, 2, 4, 5, 6] print(tuple(li))  # Using Built-in Function tup = tuple('Geeks') print(tup) 

Output
() ('Geeks', 'For') (1, 2, 4, 5, 6) ('G', 'e', 'e', 'k', 's') 

Let's understand tuple in detail:

Creating a Tuple with Mixed Datatypes.

Tuples can contain elements of various data types, including other tuples, lists, dictionaries and even functions.

Example:

Python
tup = (5, 'Welcome', 7, 'Geeks') print(tup)  # Creating a Tuple with nested tuples tup1 = (0, 1, 2, 3) tup2 = ('python', 'geek') tup3 = (tup1, tup2) print(tup3)  # Creating a Tuple with repetition tup1 = ('Geeks',) * 3 print(tup1)  # Creating a Tuple with the use of loop tup = ('Geeks') n = 5 for i in range(int(n)):     tup = (tup,)     print(tup) 

Output
(5, 'Welcome', 7, 'Geeks') ((0, 1, 2, 3), ('python', 'geek')) ('Geeks', 'Geeks', 'Geeks') ('Geeks',) (('Geeks',),) ((('Geeks',),),) (((('Geeks',),),),) ((((('Geeks',),),),),) 

Python Tuple Basic Operations

Below are the Python tuple operations.

  • Accessing of Python Tuples
  • Concatenation of Tuples
  • Slicing of Tuple
  • Deleting a Tuple

Accessing of Tuples

We can access the elements of a tuple by using indexing and slicing, similar to how we access elements in a list. Indexing starts at 0 for the first element and goes up to n-1, where n is the number of elements in the tuple. Negative indexing starts from -1 for the last element and goes backward.

Example:

Python
# Accessing Tuple with Indexing tup = tuple("Geeks") print(tup[0])  # Accessing a range of elements using slicing print(tup[1:4])   print(tup[:3])  # Tuple unpacking tup = ("Geeks", "For", "Geeks")  # This line unpack values of Tuple1 a, b, c = tup print(a) print(b) print(c) 

Output
G ('e', 'e', 'k') ('G', 'e', 'e') Geeks For Geeks 

Concatenation of Tuples

Tuples can be concatenated using the + operator. This operation combines two or more tuples to create a new tuple.

Note: Only the same datatypes can be combined with concatenation, an error arises if a list and a tuple are combined. 

Python
tup1 = (0, 1, 2, 3) tup2 = ('Geeks', 'For', 'Geeks')  tup3 = tup1 + tup2 print(tup3) 

Output
(0, 1, 2, 3, 'Geeks', 'For', 'Geeks') 

Slicing of Tuple

Slicing a tuple means creating a new tuple from a subset of elements of the original tuple. The slicing syntax is tuple[start:stop:step].

Note- Negative Increment values can also be used to reverse the sequence of Tuples. 

Python
tup = tuple('GEEKSFORGEEKS')  # Removing First element print(tup[1:])  # Reversing the Tuple print(tup[::-1])  # Printing elements of a Range print(tup[4:9]) 

Output
('E', 'E', 'K', 'S', 'F', 'O', 'R', 'G', 'E', 'E', 'K', 'S') ('S', 'K', 'E', 'E', 'G', 'R', 'O', 'F', 'S', 'K', 'E', 'E', 'G') ('S', 'F', 'O', 'R', 'G') 

Deleting a Tuple

Since tuples are immutable, we cannot delete individual elements of a tuple. However, we can delete an entire tuple using del statement.

Note: Printing of Tuple after deletion results in an Error. 

Python
tup = (0, 1, 2, 3, 4) del tup  print(tup) 

Output

ERROR!
Traceback (most recent call last):
File "<main.py>", line 6, in <module>
NameError: name 'tup' is not defined

Recent Articles on Tuple

Tuples Programs

  • Print unique rows in a given boolean Strings
  • Program to generate all possible valid IP addresses from given string
  • Python Dictionary to find mirror characters in a string
  • Generate two output strings depending upon occurrence of character in input string in Python
  • Python groupby method to remove all consecutive duplicates
  • Convert a list of characters into a string
  • Remove empty tuples from a list
  • Reversing a Tuple
  • Python Set symmetric_difference()
  • Convert a list of Tuples into Dictionary
  • Sort a tuple by its float element
  • Count occurrences of an element in a Tuple
  • Count the elements in a list until an element is a Tuple
  • Sort Tuples in Increasing Order by any key
  • Namedtuple in Python 

Useful Links:

  • Output of Python Programs
  • Recent Articles on Python Tuples
  • Multiple Choice Questions – Python
  • All articles in Python Category

Next Article
Tuple Operations in Python

A

abhishek1
Improve
Article Tags :
  • Misc
  • Python
  • python-tuple
Practice Tags :
  • Misc
  • python

Similar Reads

    Python Tuples
    A tuple in Python is an immutable ordered collection of elements. Tuples are similar to lists, but unlike lists, they cannot be changed after their creation (i.e., they are immutable). Tuples can hold elements of different data types. The main characteristics of tuples are being ordered , heterogene
    6 min read
    Tuple Operations in Python
    Python Tuple is a collection of objects separated by commas. A tuple is similar to a Python list in terms of indexing, nested objects, and repetition but the main difference between both is Python tuple is immutable, unlike the Python list which is mutable.Python# Note : In case of list, we use squa
    7 min read
    Create a List of Tuples in Python
    The task of creating a list of tuples in Python involves combining or transforming multiple data elements into a sequence of tuples within a list. Tuples are immutable, making them useful when storing fixed pairs or groups of values, while lists offer flexibility for dynamic collections. For example
    3 min read
    Create a tuple from string and list - Python
    The task of creating a tuple from a string and a list in Python involves combining elements from both data types into a single tuple. The list elements are added as individual items and the string is treated as a single element within the tuple. For example, given a = ["gfg", "is"] and b = "best", t
    3 min read
    Access front and rear element of Python tuple
    Sometimes, while working with records, we can have a problem in which we need to access the initial and last data of a particular record. This kind of problem can have application in many domains. Let's discuss some ways in which this problem can be solved. Method #1: Using Access Brackets We can pe
    6 min read
    Python - Element Index in Range Tuples
    Sometimes, while working with Python data, we can have a problem in which we need to find the element position in continuous equi ranged tuples in list. This problem has applications in many domains including day-day programming and competitive programming. Let's discuss certain ways in which this t
    7 min read
    Unpacking a Tuple in Python
    Tuple unpacking is a powerful feature in Python that allows you to assign the values of a tuple to multiple variables in a single line. This technique makes your code more readable and efficient. In other words, It is a process where we extract values from a tuple and assign them to variables in a s
    2 min read
    Unpacking Nested Tuples-Python
    The task of unpacking nested tuples in Python involves iterating through a list of tuples, extracting values from both the outer and inner tuples and restructuring them into a flattened format. For example, a = [(4, (5, 'Gfg')), (7, (8, 6))] becomes [(4, 5, 'Gfg'), (7, 8, 6)].Using list comprehensio
    3 min read
    Python | Slice String from Tuple ranges
    Sometimes, while working with data, we can have a problem in which we need to perform the removal from strings depending on specified substring ranges. Let's discuss certain ways in which this task can be performed. Method #1: Using loop + list slicing: This is the brute force task to perform this t
    3 min read
    Python - Clearing a tuple
    Sometimes, while working with Records data, we can have a problem in which we may require to perform clearing of data records. Tuples, being immutable cannot be modified and hence makes this job tough. Let's discuss certain ways in which this task can be performed. Method #1 : Using list() + clear()
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences