Python Collectoin Part-3

For Professionals and Freshers 


Tuple :

If you want to represent group of object where duplication are allowed and  insertion order must be preserved but i want immutability then we go for Tuple.

Difference between list and tuple is , list is mutable where as tuple is immutable in nature.

() by using parenthesis we can represents tuple , where as by using [] we can represents list.

Once we can create tuple , we cant change its content.

t=(12,'govind',True,10)
print(t)

t[0]
output: 12

t[-1]
output: 10

t[0:3]
output: 12 govind True

Example 2:

t=(10,12,[2,6])

In this example we can store list inside tuple , yes it is valid.


Comments

Popular posts from this blog

Filter In Javafx

Kotlin with StandAlone Complier