# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# <small><small><i>
# All the IPython Notebooks in this lecture series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/02_Python_Datatypes/tree/main/002_Python_String_Methods)**
# </i></small></small>

# # Python String `center()`
#
# The **`center()`** method returns a string which is padded with the specified character.
#
# **Syntax**:
#
# ```python
# string.center(width[, fillchar])
# ```

# ## `center()` Parameters
#
# The **`center()`** method takes two arguments:
#
# * **width** - length of the string with padded characters
# * **fillchar** (optional) - padding character
#
# The **`fillchar`** argument is optional. If it's not provided, space is taken as default argument.

# ## Return Value from `center()`
#
# The **`center()`** method returns a string padded with specified **`fillchar`**. It doesn't modify the original string.

# +
# Example 1: center() Method With Default fillchar

string = "Python is awesome"

new_string = string.center(24)

print("Centered String: ", new_string)

# +
# Example 2: center() Method With * fillchar

string = "Python is awesome"

new_string = string.center(24, '*')

print("Centered String: ", new_string)
# -



StarcoderdataJupyterScriptsDedupFiltered