YouTip LogoYouTip

Python3 String Ljust

# Python3.x Python3 ljust() Method [![Image 3: Python3 Strings](#) Python3 Strings](#) * * * ## Description The `ljust()` method returns a left-justified version of the original string, padded with spaces to a specified length. If the specified length is less than the original string's length, the original string is returned. ## Syntax The syntax for the `ljust()` method is: str.ljust(width[, fillchar]) ## Parameters * `width` -- Specifies the desired string length. * `fillchar` -- The character to pad with, defaults to a space. ## Return Value Returns a left-justified version of the original string, padded with spaces to a specified length. If the specified length is less than the original string's length, the original string is returned. ## Example The following example demonstrates the use of `ljust()`: #!/usr/bin/python3 str = " example....wow!!!"print (str.ljust(50, '*')) The output of the above example is: example....wow!!!************************** * * Python3 Strings](#)
← Git MvGit Reset β†’