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 | Find the tuples containing the given element from a list of tuples
- Python | Remove tuples having duplicate first value from given list of tuples
- Python | Count tuples occurrence in list of tuples
- Python | Remove tuples from list of tuples if greater than n
- Python program to create a list of tuples from given list having number and its cube in each tuple
- Python | Convert list of tuples to list of strings
- Python | Convert list of tuples to list of list
- Python Program for Linear Search
- 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
- Python | Group tuples in list with same first value
- Python | Unzip a list of tuples
- Python | Convert a list of Tuples into Dictionary
- Python | Selective value selection 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 firstname.lastname@example.org. 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.