Python String ljust() MethodPython Functions

Difficulty Level:
Difficulty Level:

The string ljust() method returns a left-justified string of given minimum width.

Example

#!/usr/bin/python3

str = "Python is the most famous language.!!!"

print (str.ljust(50, '*'))

Output:

Python is the most famous language.!!!************

Syntax

string.ljust(width[, fillchar])

Parameters

Name Description
width Specifies the length of the string
Fillchar Padding character, defaults to a space

Return Value

It returns the left-justified string within the given minimum width.

Advertisement

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