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
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python | Remove duplicate tuples from list of tuples
- Python | Find the tuples containing the given element from a list of tuples
- Python | Remove tuples from list of tuples if greater than n
- Python | Remove tuples having duplicate first value from given list of tuples
- Python | Count tuples occurrence in list of tuples
- Python | Combining tuples in list of tuples
- Python | Convert string tuples to list tuples
- Python - Filter all uppercase characters Tuples from given list of tuples
- Python program to find Tuples with positive elements in List of tuples
- Python program to find tuples which have all elements divisible by K from a list of tuples
- Python | How to Concatenate tuples to nested tuples
- Python | Convert list of tuples to list of list
- Python | Search in Nth column 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 tuples into list
- Python | Convert list of tuples to list of strings
- Python | Update a list of tuples using another list
- Python | Convert list of strings to list of tuples
- Python - Add list elements to tuples list
- Python - Convert Tuple value list to 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.