Python Programming - Data Types - Discussion

Discussion Forum : Data Types - General Questions (Q.No. 60)
60.
What is the output of the following code snippet?
my_tuple = (1, 2, 3, 4, 5)
result = my_tuple.index(3)
print(result)
2
3
4
Error
Answer: Option
Explanation:
The index() method in Python returns the index of the first occurrence of the specified element in the tuple. In this case, the element 3 is at index 2 in the tuple my_tuple, so 2 will be printed.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.