Computer Science, asked by kanishk4432, 2 months ago

Python program to Input a list/tuple of elements, search for a given element in the list/tuple and frequency and position of search element.

Answers

Answered by sharmavinay84479
3

Answer:

Input: n = 11, list = [(11, 22), (33, 55), (55, 77), (11, 44)]

Output: [(11, 22), (11, 44)]

Input: n = 3, list = [(14, 3),(23, 41),(33, 62),(1, 3),(3, 3)]

Output: [(14, 3), (1, 3), (3, 3)]

Answered by anvisha27008
3

Answer: given a list of tuples, the task is to find all those tuples containing the given element, say n.

Examples:

Input: n = 11, list = [(11, 22), (33, 55), (55, 77), (11, 44)]

Output: [(11, 22), (11, 44)]

Input: n = 3, list = [(14, 3),(23, 41),(33, 62),(1, 3),(3, 3)]

Output: [(14, 3), (1, 3), (3, 3)]

There are multiple ways we can find the tuples containing the given element from a list of tuples. Let’s see some of Pythonic ways to do this task.

Explanation:

Similar questions