# Linear Search
import sys
list1 = [11,22,13,44,65,56,87,88,79,10]
num = int(input("Enter element to search : "))
for ind in range(0, len(list1),1):
if (list1[ind] == num):
print("Element", num, "present at index", ind)
sys.exit(0)
print("Element not present in list")
import sys
list1 = [11,22,13,44,65,56,87,88,79,10]
num = int(input("Enter element to search : "))
for ind in range(0, len(list1),1):
if (list1[ind] == num):
print("Element", num, "present at index", ind)
sys.exit(0)
print("Element not present in list")
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu