PythonStringljust
zfill

ljustString

rjust

Returns the string left-justified in a field of given width.

Syntax

str.ljust(width, fillchar?)

Example

Enter values below to update the example in real time.

print
ljust
text = "hi"
print(text.ljust(10))        # "hi        "
print(text.ljust(10, "-"))   # "hi--------"