Python String ljust() method

The string.ljust() method in Python will left align the string, where the padding is done using the parameter fillchar (space is default).

Syntax

Parameter

width: This parameter represents the length of the returned string.

fillchar(Optional): This parameter represents a character to fill the missing space (to the right of the string). Default is ” ” (space).

Return

This method returns the string left a justified string of the given width. The original string is returned if the width is less than the length of the String.

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This