Sahithyan's S1 — Programming Fundamentals
String formatting
Techniques used to create formatted strings by embedding expressions within string literals. Here are the main methods:
%
Operator
Older and less preferred now.
str.format()
Method
More flexible and readable than the %
operator.
f-strings
Most concise and readable way to format strings. Expressions can be embedded
inside string literals using curly braces {}
. Supports more complex
expressions as well.