+ 1
how hello world is going to other. instead of spam in this code given
class SpecialString: def __init__(self, cont): self.cont = cont def __truediv__(self, other): line = "=" * len(other.cont) return "\n".join([self.cont, line, other.cont]) spam = SpecialString("spam") hello = SpecialString("Hello world!") print(spam / hello)
2 Antworten
+ 2
I don't think i fully understand your question, but "spam" refers to self.cont while "Hello world!" refers to self.other
0
1. As per my understanding, you are using constructor to call class and getting same output as input.
2. Please ask question properly so that we can answer it properly.