Overloading Multiplication Operator
Mon 10 August 2026
class Repeater:
def __init__(self, text):
self.text = text
def __mul__(self, times):
return self.text * times
r = Repeater("AI ")
print(r * 3) # Output: AI AI AI
AI AI AI
Score: 10
Category: chapter5_operator_overloading