In [3]:

center(width[, fillchar])

2025-05-29 13:18

Centers the string within the specified width.

### center(width[, fillchar])

**Description:**
Returns a centered string of length width. Padding is done using the specified fill character (default is space).

**Example:**
“`python
text = “hello”
print(text.center(11, “-“)) # Output: ‘—hello—‘
“`

**Use Case:**
Helpful in creating formatted outputs, such as console tables or UI elements.