String Methods
str.rjust()
Pad the left side to right-align text. Width is a minimum code-point length, not a visual column width. No truncation occurs. The original string is unchanged.
Formal Syntax & Structure
python syntaxpython
text.rjust(width, fillchar=" ", /)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| width | int | Minimum result length in Unicode code points; accepts index-compatible integers. |
| fillchar | str | Exactly one code point; defaults to ASCII space. |
Return Value
str
Padded text, or unchanged text when width is no larger than its length.
Working Example
Example Snippetpython
print("7".rjust(4))print("42".rjust(4, "0"))