Easy Tutorial
❮ Python Os Fstat Python Merge Sort ❯

Python3 ljust() Method

Python3 Strings


Description

The ljust() method returns the original string left-aligned and padded with spaces to a specified length. If the specified length is less than the length of the original string, it returns the original string.

Syntax

Syntax for the ljust() method:

str.ljust(width[, fillchar])

Parameters

Return Value

Returns the original string left-aligned and padded with spaces to the specified length. If the specified length is less than the length of the original string, it returns the original string.

Example

The following example demonstrates the use of ljust():

#!/usr/bin/python3

str = "tutorialpro example....wow!!!"

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

The output of the above example is:

tutorialpro example....wow!!!**************************

Python3 Strings

❮ Python Os Fstat Python Merge Sort ❯