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)

17th Jul 2018, 11:49 AM
adarsh pandey
adarsh pandey - avatar
4 odpowiedzi
+ 1
join is used here to add a newline between self.cont, line and other.cont
17th Jul 2018, 12:25 PM
Satyam
+ 1
how?
20th Jul 2018, 12:05 PM
Satyam
0
but that could have been done by \n
20th Jul 2018, 11:42 AM
adarsh pandey
adarsh pandey - avatar
0
but that could have been done by \n
20th Jul 2018, 11:42 AM
adarsh pandey
adarsh pandey - avatar