Python Placeholder

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

Python placeholder

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

Python placeholder hold place tutorialbrain

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.

Example

Python numeric placeholder

Directly Passing a value

You can directly pass a value instead of a variable. For %s, you can pass a string but if you use %d, you have to pass a Numeric value.

Example

Python placeholder static value tutorialbrain

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 –

Example

Python placeholder multiple placeholders

Tutorials for all brains!