Input a list/tuple of elements and search for a given element in the list/tuple Python Program
# Python Program to input a list of 5 elements and search element in List
mylist = [] print("Enter 5 elements for the list: ") for i in range(5): value = int(input()) mylist.append(value) print("Enter an element to be search: ") element = int(input()) for i in range(5): if element == mylist[i]: print("\nElement found at Index:", i) print("Element found at Position:", i+1)
Output:
Enter 5 elements for the list: 45 34 37 34 55 Enter an element to be search: 34 ('\nElement found at Index:', 1) ('Element found at Position:', 2) ('\nElement found at Index:', 3) ('Element found at Position:', 4) >>>
You may also Check :
-
Find the largest/smallest number in a list/tuple
-
Input a list of numbers and swap elements at the even location with the elements at the odd location.
-
Input a list of numbers and find the smallest and largest number from the list.
-
Create a dictionary with the roll number, name and marks of n students in a class and display the names of students who have scored marks above 75.