Input a list/tuple of elements and search for a given element in the list/tuple Python Program

Last updated on February 8th, 2022 at 11:25 am

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 :

 

 

Jitendra Singh
✔ Verified Educator

Jitendra Singh

Founder of CBSEPython.in

I help CBSE Class 9–12 students learn Python, Information Technology, Artificial Intelligence and Computer Science through easy notes, quizzes, MCQs and sample papers.

Read More About Me →

Leave a Comment

error: Content is protected !!