Python3 rjust () method
description
rjust () Returns a string of former right-aligned and padded with spaces to the new string of length width. If the length is less than the length of the string is the original string is returned.
grammar
rjust () method syntax:
str.rjust(width[, fillchar])
parameter
- width - Specifies the fill character specified after the total length of the string.
- fillchar - filled characters, the default is spaces.
return value
Returns a string of former right-aligned and padded with spaces to the new string of length width. If the length is less than the length of the string is returned the original string
Examples
The following example shows rjust () function to use:
#!/usr/bin/python3 str = "this is string example....wow!!!" print (str.rjust(50, '*'))
Examples of the above output results are as follows:
******************this is string example....wow!!!