डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

डिप्लोमा इन ऑफिस मैनेजमेंट एण्ड अकाउटिंग

Full Stack Web Development with Laravel

Full Stack Web Development with Laravel

Affiliate Program

Affiliate Program

Python Tuple

Tuple is used to store multiple values. tuple created using small brackets ()
 
t= (1, 2, 3)
 
Tuple are immutable.
 

Print tuple

t=(1,2,3)
print(t)
 

Tuple Indexing

t=(1,2,3)
print(t[0]) # 1
 

Tuple splitting 

t=(1,2,3)
print( t[0:2] ) # (1, 2)
 

Tuple looping

t=(1, 2, 3)
for item in t:
     print(item)

Tuple methods

index(item) Return index of given item from a tuple
t=(1,2,3)
print(t.index(1)) # 0
count(item) Return number of item of specified item from a tuple
t=(1,2,3,1)
print(t.count(1)) # 2
© 2016 - 2023, All Rights are Reserved.