Python String rjust() MethodPython Functions

Difficulty Level:
Difficulty Level:

The rjust() method returns a right-justified string of given minimum width.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

str = "Jason Statham is the most famous actor in Hollywood.!!!"
print (str.rjust(70, '*'))

Output:

***************Jason Statham is the most famous actor in Hollywood.!!!

Syntax

string.rjust(width[, fillchar])

Parameters

Name Description
width Width of the given string
fillchar Character to fill the remaining space of the width

Return Value

It returns the string right justified in a string of length width.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us