String formatting in python is used to inject several items in a string at a time rather than using concatenation to add items within a string, which can be confusing sometimes.
There are three different methods of performing string formatting:
- The old method of using placeholders with modulo %
- An improved way of using .format() string method.
- The latest method uses formatted string literals called f-strings, introduced with Python 3.6.
Let’s start formatting with placeholders…