Python Placeholder
In Python, Placeholder is a word, characters or a string of characters to hold a temporary place.
The placeholder behaves as a dynamic place holder in such a way that you can pass a particular value for that placeholder.
Example
Here, you can see that ‘%s‘ is the string placeholder which can hold a string in this place.
The placeholder will be replaced by the value of another variable or the static value itself.
This will be clear from the next example.
Example
Here, you can see that ‘%s‘ will hold a place(value) from %tutorial and the value of tutorial is “TutorialBrain”
Hence, print(ph%tutorial) displays –
TutorialBrain is the best Python Learning Website.
Consider the example below -
Example
Directly Passing a value
Example
Python Multiple Placeholder Declaration
You can code any number of placeholders.
If you code 2 placeholders, you have 2 pass 2 values via the argument as below –
Python Multiple Placeholder Declaration
You can code any number of placeholders.
If you code 2 placeholders, you have 2 pass 2 values via the argument as below –