Answer to Question #223512 in Python for Ravan

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")
1
Expert's answer
2021-08-06T04:21:31-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS