Python3 rjust() method
Description
rjust() returns a new string with the original string right-aligned and padded with spaces to a length of width. If the specified length is less than the length of the string, the original string is returned.
Syntax
The syntax of the rjust() method is:
str.rjust(width[, fillchar])
Parameters
- width -- Specifies the total length of the string after padding with the specified character.
- fillchar -- The character to pad with, defaults to a space.
Return Value
Returns a new string with the original string right-aligned and padded with spaces to a length of width. If the specified length is less than the length of the string, the original string is returned.
Example
The following example demonstrates the usage of the rjust() function:
#!/usr/bin/python3 str = "this is string example....wow!!!" print (str.rjust(50, '*'))
The output of the above example is as follows:
******************this is string example....wow!!!
Other Extensions
Python3 String