![]() |
VOOZH | about |
Strings are sequences of characters that we can manipulate in many ways. Sometimes we need to align a string to the left, right, or centre within a given space. In this article, we will explore the Difference between ljust(), just() and center().
Table of Content
ljust() method is used to align a string to the left side and fill the remaining space on the right with a specific character (or space by default).
string.ljust(width, fillchar)Burger--------------
The rjust() method aligns the string to the right side and fills the remaining space on the left with a specific character (or space by default).
string.rjust(width, fillchar)
-----Hello
The center() method centers the string in the middle and fills both sides with a specific character (or space by default) to achieve a given width.
string.center(width, fillchar)
--Hello---