Strings & text
Easy
Split and join words
Turn a sentence into tokens, then rebuild it with a custom separator.
How it works
str.split() breaks text on whitespace by default. Pass a delimiter to split on commas, pipes, or any character.
str.join() is the inverse: call it on the separator string and pass an iterable of pieces.
Together they are perfect for parsing simple CSV-like input without importing the csv module.
raw = "python split join example"
words = raw.split()
print(words)
joined = "-".join(words)
print(joined)
csv_line = "red,green,blue"
colors = csv_line.split(",")
print(" | ".join(colors))
Sponsored
Sponsored
Reserved space — layout preview until AdSense is connected