Question #223512

How to make object as callable video __call__
from collections import Counter
class MyCounter(Counter):
Add here required code so that we can give data to object like co1("intel")
co1 = MyCounter()
co1("intel")

Expert's answer

from collections import Counter


class MyCounter(Counter):
    data=""
    def _init_(self):
        pass
        
    def _call_(self,a):
        a=Counter(a)
        for i in a.elements():
            print ( i, end = " ")
     


 
co1 = MyCounter()


co1("intel")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS