May 2017
Intermediate to advanced
280 pages
6h 2m
English
methods to deal with these types of situations.
In many situations, you might need to justify the string length. The requirement may be string, which must possess a certain length. We have four string methods to deal with these types of situations. Let's start from ljust(), which means left justify.
The syntax for the method is given as follows:
str1.ljust(width[, fillchar])
When you provide the string to the ljust() method, it returns the string left justified. The minimum string length is specified by width and the padding on the left side is specified by the fillchar character(s), the space is default.
Consider the following examples:
>>> str1= "Mohit Raj">>> str1.ljust(15, "#")'Mohit Raj######'>>> >>> str2= ...
Read now
Unlock full access