The rjust() method in Python string is responsible for returning the string right which is justified in a string of the length width. Padding is done making use of the specified fillchar where space is the default one. The original string is therefore returned when the width is less than len(s).
Here is the syntax for rjust() method:
str.rjust(width[, fillchar])
This method in Python string returns the string which is right-justified within a string of length width. Padding is done making use of the specified fillchar where the default is the space. The original string is thus returned in case the width is lesser than len(s).
The example below shows the usage of rjust() method.
#!/usr/bin/python str = "this is string example....wow!!!"; print str.rjust(50, '0')
When the above program is run, it produces the following result:
000000000000000000this is string example....wow!!!
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.