Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

frequency of occurrence of that element in the list and the positions

#search for the occurrence of an element ina list using linear search. Find the
#frequency ofoccurrence of that element in the list and thepositions
________________________________________________________________________________
a=eval(input('Enter the list of number:'))
b=int(input('Enter the element to be searched :'))
index=[]
count=0
for i in range(len(a)):
 if a[i]==b:
  count+=1
  index.append(i)
print(b,'found',count,'times')
print(b,'is present at positions',index)
________________________________________________________________________________
#output:
--------------------------------------------------------------------------------
Enter the list of number:[7,1,5,7,9,66,1,4]
Enter the element to be searched :7
7 found 2 times
7 is present at positions [0, 3]
--------------------------------------------------------------------------------
Comment

PREVIOUS NEXT
Code Example
Python :: how to clear checkbox in tkinter 
Python :: polynomial features random forest classifier 
Python :: How to add card in trello API using python 
Python :: change the style of notebook tkinter 
Python :: how to convert 24 hours to 12 hours in python 
Python :: phi 
Python :: extract image from pdf python 
Python :: where to find python3 interpreter 
Python :: python list to string with spaces 
Python :: python random phone number 
Python :: twilio python 
Python :: rabbitmq pika username password 
Python :: likeliness python 
Python :: alarm when code finishes 
Python :: panda - subset based on column value 
Python :: how to remove all characters from a string in python 
Python :: python input map 
Python :: jupyter themes 
Python :: python selenium screenshot 
Python :: pandas subtract integer from column 
Python :: python list rotation 
Python :: sorted python lambda 
Python :: nlargest 
Python :: os file exists 
Python :: calculate root mean square error python 
Python :: hello world flask python 
Python :: union df pandas 
Python :: climate change 
Python :: degrees to radians python 
Python :: how to change the title of a tkinter widnow 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =