/  ijust() method in Python String Module

ijust() method in Python String Module


ijust methodin string module returns the left justified string from the position of the index given.


Syntax

Str.ljust ()


Parameters:

ijust has 2 parameters

  1. Width: it is the width of the given string. If it is less or equal to the original strung then it returns the original string.
  2. Fillchar: this is an optional parameter. It is used to fill in the empty spaces available in the string


Example-1:


Using width:

text = "Switzerland"
x = text.ljust(25)
print(x, "is my favorite place.")


Output :


Example 2:


Using fillchar

string = 'Nepal'
width = 10
fillchar = '*'
print(string.ljust(width, fillchar))	


Output: