Nowy kurs! Każdy programista powinien nauczyć się Generative AI!
Wypróbuj darmową lekcję0
In python when is it advantageous to use 'sep' over 'join' or 'end'?
Whats the best time to use join or end or sep?
1 Odpowiedź
+ 2
These are not really comparable I think, 'sep' and 'end' are attributes used along with `print` function.
sep - Defines a character/string used as delimiter between arguments to print. By default, Python uses space for this.
end - Defines a character/string to be printed after all the arguments had been printed. By default, Python uses line break for this.
`join` is a method from `str` class that we can use to "glue" multiple string together to form a single string.
Each of them has their own purpose and use cases, not comparable by advantage or timing : )