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