Tuple in python ( with example )

Tuples is a collection of related data . Tuples is a collection of ordered and immutable data . Immutable things can’t change . In python tuples are written with round brackets .

How to create a tuple ?

Run example

Access Tuple items

Run program

Negative Indexing

Run example

Range of indexes :

You can define the range of indexes where to start and where to end .

The search will start at index (1) and end with index(5).. Run the following program is .

Range of negative indexes

Negative indexes if you want to start search then start the search from end .

The example returns the items from indexes (-4) to indexes (-2) .

Here we know about lists and tuple . What’s the difference between lists and tuple in python .

Lists .

1. Lists are ordered

2. Lists are mutable

3. Lists are dynamic


1. Tuple are defined by ()

2. Tuple are immutable .

Note. Next blog will be on python Dictionary .

Leave a Comment

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