Home >>Python String Methods >Python String rjust() Method

Python String rjust() Method

Python String rjust() Method

Python String rjust() Method in python returns the string right justify and fill the remaining spaces with specified fill character.

Syntax:
string.rjust(length, character)

Parameter Values

Parameter Description
length It is Required the width of the returned string
character It is Optional character to fill the missing space in the string.
Here is an example of Python String rjust() Method:

RJust = "five"
c = RJust.rjust(25)
print(c, "is my lucky number.")

Output:
               five is my lucky number
Example 2:

str = 'phptpoint'   
str = str.rjust(12,"O")  
print(str)  

Output:
OOOphptpoint

No Sidebar ads