Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python3 rjust() Method

Python3 rjust() Method

Python3 Strings Python3 Strings


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

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 Python3 Strings