Python String center() method
ইনস্ট্যান্স
শব্দ "banana" প্রিন্ট করুন যা 20 চারিদিকে বিস্তৃত হবে এবং "banana"-কে মধ্যে রাখবে:
txt = "banana" x = txt.center(20) print(x)
definition and usage
center() method will use the specified character (default is space) as the padding character to center align the string.
syntax
string.center(length, character)
parameter value
parameter | description |
---|---|
length | প্রয়োজনীয়। ফলাফলকার স্ট্রিংয়ের দৈর্ঘ্য |
character | অপশনাল। দুই পাশের অভাব পূরণকারী অক্ষর। ডিফল্ট হল " " (খালি)। |
আরও ইনস্ট্যান্স
ইনস্ট্যান্স
পূরণ করার জন্য ব্যবহার্য অক্ষর "O" হিসাবে ব্যবহার করুন:
txt = "banana" x = txt.center(20, "O") print(x)