Python String rjust() Method
Right justifies a string, left-padding with the specified character or substring to the specified width.
Syntax
Python
Copy Code
string.rjust(length, character = " ")
Parameters
Parameter | Description |
---|---|
length |
Required. The length of the final string. If length is less than the length of the supplied. |
character |
Optional. The character to use for padding the string. Default is a space (" ") |
Example
Python
Copy Code
print('ABC'.rjust(20, '-'))
Output
-----------------ABC