0
What is the use of join here plz say what's happening here
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)
4 Antworten
+ 1
join is used here to add a newline between self.cont, line and other.cont
+ 1
how?
0
but that could have been done by \n
0
but that could have been done by \n