Let’s see a basic linear search operation on Python list and tuples.
A simple approach is to do linear search, i.e
- Start from the leftmost element of list and one by one compare x with each element of the list.
- If x matches with an element, return True.
- If x doesn’t match with any of elements, return False.
Example #1: Linear Search on Lists
Note that list are mutable but tuples are not.
Example #2: Linear Search in Tuple
- Python | Search in Nth column in list of tuples
- Python | Remove tuples having duplicate first value from given list of tuples
- Python | Remove duplicate tuples from list of tuples
- Python | Count tuples occurrence in list of tuples
- Python | Remove tuples from list of tuples if greater than n
- Python | Find the tuples containing the given element from a list of tuples
- Python | Combining tuples in list of tuples
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python | Convert list of strings to list of tuples
- Python | Convert list of tuples to list of strings
- Python Program for Linear Search
- Python | Convert list of tuples to list of list
- Python | Update a list of tuples using another list
- Python | Convert list of tuples into list
- Python | Min and Max value in list of tuples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.