0% found this document useful (0 votes)
61 views2 pages

Python Element Search in List

Uploaded by

kalash satypal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views2 pages

Python Element Search in List

Uploaded by

kalash satypal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Code:

print(end="Enter the Size: ")


arrSize = int(input())
print("Enter " +str(arrSize)+ " Elements: ")
arr = []
for i in range(arrSize):
arr.append(input())
print("Enter an Element to Search: ")
elem = input()
chk = 0
for i in range(arrSize):
if elem==arr[i]:
index = i
chk = 1
break
if chk==1:
print("\nElement Found at Index Number: " + str(index))
else:
print("\nElement doesn't found!")
Output:

1.not found
Enter the Size: 5
Enter 5 Elements:
12
32
51
63
9
Enter an Element to Search:
90
Element doesn't found!

2.Element found:
Enter the Size: 5
Enter 5 Elements:
23
2
5
65
67
Enter an Element to Search:
5
Element Found at Index Number: 2

You might also like