Python string ljust() method
উদাহরণ
Returns the left-aligned version of the word "banana" with a length of 20 characters:
txt = "banana" x = txt.ljust(20) print(x, "is my favorite fruit.")
note: as a result, the right side of the word "banana" actually has 14 spaces.
definition and usage
ljust() method uses the specified character (default is space) as the padding character to align the string to the left.
syntax
string.ljust(length, character)
parameter value
parameter | description |
---|---|
length | প্রয়োজনীয়। ফলাফলস্বরূপ স্ট্রিংসমূহের দৈর্ঘ্য |
character | বাছাইযোগ্য। স্ট্রিংসমূহের বাম দিকের অক্ষরগুলির মধ্যে বাকা জায়গা পূরণ করার জন্য ব্যবহৃত অক্ষর। ডিফল্ট মান " " (খালি)। |
আরও উদাহরণ
উদাহরণ
পূরণকৃত অক্ষর "O" ব্যবহার করে:
txt = "banana" x = txt.ljust(20, "O") print(x)