Home >>Python String Methods >Python String ljust() Method
Python String ljust() Method in python will returns the string left align and fill the remaining spaces with fillchars (default is a space).
Syntax:string.ljust(length, character)
Parameter | Description |
---|---|
length | It is required the returned string length |
character | It is Optional, character to fill the missing space in the string. Default is " " (space). |
just = "white"
x = just.ljust(25)
print(x, "is my favorite color.")
white is my favorite color.
str = 'Phptpoint'
str = str.ljust(25,":")
print(str)