1.

Program to Input a list/tuple of elements, search for a given element in the list/tuple and frequency and position of searchelement.

Answer»

Program:

L = []

N = int(input("Enter no. of ELEMENTS in the list : "))

print("Enter elements in the list : ")

for i in range(0 , n):

   ele = input()

   L.append(ele)

Search = input("Enter element to search : ")

C = 0

for i in range(0 , n):

   if L[i] == Search:

       c = c + 1

       print("Present at POSITION : " , i)

if c > 0 :

   print("Frequency : " , c)

else:

   print("Element not found")



Discussion

No Comment Found