Function Details: ljust

Description


Return left-justified string of length width.


Extended Description


The ljust() method returns a left-justified string of specified width. If the original string is shorter than the specified width, it pads the string on the right with the specified fill character (space by default) to reach the desired width. If the original string is longer than or equal to the specified width, it returns the original string unchanged.


Read More about ljust from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • width: int
  • fillchar: str

Return


Returns a new string of specified width with the original string left-justified.


Return Type


str

Output

Explanation

This example demonstrates the basic usage of ljust(). It pads the string on the right with '-' to reach a width of 10.