Python

Python Menu

Python

Python String rjust() - Definition, Syntax, Parameters, Examples

Definition

The rjust() method will right align the string, using a specified character (space is default) as the fill character.

Syntax

string.rjust(length, char)

Parameters

Parameter Description
length Required. The length of the returned string
char Optional. A character to fill the missing space (to the left of the string). Default is space.

Examples:

testStr = "Python" result = testStr.rjust(20) print(result, "is a programming language.") # using padding a character testStr = "Python" result = testStr.rjust(20, "x") print(result)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods