join combines strings from a sequence into one string, placing the string before .join() between adjacent elements. It is the natural counterpart to split(). section 6.4.1
Use the separator to control the resulting format:
- Prefer join over repeated + concatenation when combining many strings, because repeated + creates additional string objects. section 6.4.1
Turn words into one word per line
words = cleaned_line.split() cleaned_words = "\n".join(words) Splitting removes the line's whitespace boundaries; joining with "\n" produces text with one word on each line, ready to write to a file. section 6.10.2
join creates a new string rather than changing existing strings. It can also rebuild a string after list-based character manipulation, but repeated conversions may become expensive at very large scale. section 6.4.6





