How to Use String rjust() Method in PythonPython Basics


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.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us