Python/Text & files 7 min

String methods

Split, join, strip and reshape text.

splitjoinformat

Strings are immutable: every method returns a new string. split and join are the pair you reach for most — one turns text into a list, the other turns a list back into text.

python · editable
loading editor…

Try it: Title-case every name before joining them.

Tests and cleanup: startswith, endswith, in, replace, removeprefix and the case helpers. Compare case-insensitively by lowering both sides.

python · editable
loading editor…

f-strings format values inline, including alignment and rounding, which keeps printed output readable.

python · editable
loading editor…