Python String ljust() Method Syntax

Syntax: ljust(len, fillchr)

Parameters:

  • len: The width of string to expand it.
  • fillchr (optional): The character to fill in the remaining space.

Return: Returns a new string of given length after substituting a given character in right side of original string.

Python String ljust() Method

Python String ljust() method left aligns the string according to the width specified and fills the remaining space of the line with blank space if ‘fillchr‘ argument is not passed.

Similar Reads

Python String ljust() Method Syntax:

Syntax: ljust(len, fillchr) Parameters: len: The width of string to expand it. fillchr (optional): The character to fill in the remaining space. Return: Returns a new string of given length after substituting a given character in right side of original string....

Python String ljust() Method Example:

Python3 string = "geeks" print(string.ljust(10, '-'))...