Easy Tutorial
❮ Python Data Type Python Func Number Atan2 ❯

Python3 rjust() Method

Python3 Strings


Description

The rjust() method returns a right-justified string of a given minimum width. It pads the string with spaces on the left to achieve the specified width. If the specified width is less than the length of the string, it returns the original string.

Syntax

The syntax for the rjust() method is:

str.rjust(width[, fillchar])

Parameters

Return Value

The method returns a right-justified string of the specified width, padded with spaces on the left. If the specified width is less than the length of the string, it returns the original string.

Example

The following example demonstrates the usage of the rjust() method:

#!/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

❮ Python Data Type Python Func Number Atan2 ❯