Python Tuples

In Python Tuples are very similar to list but once a tuple is created, you cannot add, delete, replace, reorder elements.

Note: Tuples are immutable.

Creating a tuple

Tuples functions

Functions like max , min , len , sum  can also be used with tuples.

Iterating through tuples

Tuples are iterable using for loop [ Learn more about for loop here ] .

Slicing tuples

Slicing operators works same in tuples as in list and string.

in  and not in  operator

You can use in  and not in  operators to check existence of item in tuples as follows.

In next chapter we will learn about python data type conversion.

Leave a Reply

Be the First to Comment!

Notify of