rjust() This method returns the length and width to the right of the string reasonable string. Filling is done by using the specified fillchar (default is space). If the width is less than len(s), returns the original string.
grammar
The following is the syntax of the rjust() method:
(width[, fillchar])
parameter
- width -- This is the total length after the string is filled.
- fillchar -- This is a fill character, default to a space.
Return value
This method returns the length width to the right of the string reasonable string. Filling is done by using the specified fillchar (default is space). If the width is less than len(s), returns the original string.
example
The following example shows the use of the rjust() method.
#!/usr/bin/python str = "this is string example....wow!!!"; print (50, '0');
When we run the above program, it produces the following results:
000000000000000000this is string example....wow!!! str1 = "this is string example....wow!!!"; str2 = "is"; print (str2); print (str2);
When we run the above program, it produces the following results:
5 2