Function Details: rjust

Description


Returns right-justified string of length width.


Extended Description


The rjust() method returns a right-justified version of the string. It pads the string on the left with the specified fillchar (space by default) so that the resulting string has the specified width. If the input string is already longer than the specified width, it returns the original string unchanged.


Exceptions


  • TypeError: If width is not an integer or fillchar is not a single character string

Read More about rjust from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • width: int
  • fillchar: str

Return


Returns a new string of the specified width with the original string right-justified and padded on the left with the fillchar.


Return Type


str

Output

Explanation

Basic usage of rjust() to right-justify 'Python' in a field of width 10.