Answer to Question #223701 in Python for Ravan

Question #223701

Question 1:

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-05T14:22:43-0400
from collections import Counter
class MyCounter(Counter):
	def __call__(self, data):
		print(data)
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