+ 1

Why do you have to put [] inside the parentheses of "\n".join([]) ??

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 Aug 2022, 5:47 PM
Josué Varela
Josué Varela - avatar
2 odpowiedzi
+ 7
If you looked up the doc, you'd find that the argument of the join-method needs to be an iterable, for example a list
17th Aug 2022, 5:52 PM
Lisa
Lisa - avatar
+ 2
Thanks Lisa ❤️❤️❤️
19th Aug 2022, 8:46 PM
Josué Varela
Josué Varela - avatar