Aug-04-2020, 02:03 AM
Hi,
When i run this code i get
Any input is much appreciated!
When i run this code i get
(0) + (1) = (2)while i should get
Rood Groen Blauw + Geel Paars Cyaan = Rood Groen Blauw Geel Paars CyaanWhat am i doing wrong?
Any input is much appreciated!
class MyClass: def __init__(self, *args): self.Input = args def __add__(self, Other): Output = MyClass() Output.Input = self.Input + Other.Input return Output def __str__(self): Output = "" for Item in Self.Input: Output += Item Output += " " return Output Value1 = MyClass("Rood", "Groen", "Blauw") Value2 = MyClass("Geel", "Paars", "Cyaan") Value3 = Value1 + Value2 print("(0) + (1) = (2)" .format(Value1, Value2, Value3))