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 :

 

 

By cbsepython

A complete solution for the students of class 9 to 12 having subject Information Technology (402), Computer Science (083). Explore our website for all the useful content as Topic wise notes, Solved QNA, MCQs, Projects and Quiz related to the latest syllabus.

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved