elements() function in python by R4R Team

elements():
-Returns a count of each element and If an element’s count is less than one, it is ignored.


program-

#import the collections module
import collections

x=collections.Counter(a=1,b=3)
print([*x.elements()])

x=collections.Counter(a=0,b=3,c=5,d=-1)
print([*x.elements()])

x=collections.Counter(a=3,b=1,s=3,z=1)
print([*x.elements()])


output-

['a', 'b', 'b', 'b']
['b', 'b', 'b', 'c', 'c', 'c', 'c', 'c']
['a', 'a', 'a', 'b', 's', 's', 's', 'z']




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!