+ 1
how to fetch a value from tuple
4 Answers
+ 4
Like you do it with lists - by indexing.
t = (1, 2, 3)
print(t[2])
Output: 3
+ 3
Just specifying its index
For example,
tup=('4','5','6')
print(tup[1])
Output:
5
+ 2
You will find some valuable information from here
https://www.guru99.com/JUMP_LINK__&&__python__&&__JUMP_LINK-tuples-tutorial-comparing-deleting-slicing-keys-unpacking.html
+ 1
By index with square bracket like you would a list. You can use slicing just like a list also.
tup = (1,2,3)
tup[0]
tup[-1]
tup[1:]
etc...