Python String rjust() method

The string.rjust() method in Python returns a right-justified string of a given minimum width where the padding is done using the specified fillchar (default is a space). It returns the original string if the argument ‘width’ is less than the length of the string.

Syntax

string.rjust(width[, fillchar])

Parameter

width: This parameter represents the width of the given string. If width is less than or equal to the length of the string, original string is returned.

fillchar: This parameter represents the character to fill the remaining space of the width

Return

This method returns a right-justified string of a given minimum width if the specified width is more than the length of the string else it returns the original string. 

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This