Python | Search in Nth column in list of tuples
Sometimes, while working with Python list, we can have a data set that consists of tuples and we have a problem in which we need to search the element in Nth column of list. This has it’s applications in web development domain. Let’s discuss certain ways in which this task can be performed.
Method : Using
enumerate() + list comprehension
In this technique we use the power of enumerate() to access index and value in single iteration and then with the help of list comprehension we frame a conditional statement in which we check for the valid value in given column.
The original list : [('gfg', 1, 9), ('is', 5, 10), (8, 'best', 13)] Row of desired element is :