Tuples In Python

Python Collections (Arrays)

If you haven’t check out the last blog Go and read: Declare variable in python

Install Python on windows

There are four types of collection datatype in python.


In this post, we will learn about Tuple in python.

  • Tuple is similar to List only the difference is that  List values are changeable and tuple values are nonchargeable (static values).
  • Tuple is a collection of multiple data that is ordered and python list is written in square brackets.
  • Tuples are declared in circular brackets
  • Example :
Articles = ("python", "C#", "Angular",""," core")

Output : (‘python’, ‘C#’, ‘Angular’, ‘’, ‘ core’)


Access Tuple From Index

You can access the Tuple items by the index number:

Articles = ("python", "C#", "Angular",""," core")
#If you want to access the Tuple from reverse order you can use the negative index

Output :

C# core

Range of index

You can give a specific range to you are Tuple, by giving  the starting point end the ending point

When You give range to a list a new list is been created and displayed to us.

Articles = ("python", "C#", "Angular",""," core")
#By leaving out the start value, the range will start at the first item
#By leaving out the end value, the range will go on to the end of the list:
#Specify negative indexes if you want to start the search from the end of the list

Output :

(‘Angular’, ‘’)

(‘python’, ‘C#’, ‘Angular’, ‘’)

(‘C#’, ‘Angular’, ‘’, ‘ core’)

(‘C#’, ‘Angular’)


Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories