# ---
# 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 `capitalize()`
#
# In Python, the **`capitalize()`** method converts first character of a string to uppercase letter and lowercases all other characters, if any.
#
# **Syntax**:
#
# ```python
# string.capitalize()
# ```

# ## `capitalize()` Parameters
#
# The **`capitalize()`** function doesn't take any parameter.

# ## Return Value from `capitalize()`
#
# The **`capitalize()`** function returns a string with the first letter capitalized and all other characters lowercased. It doesn't modify the original string.

# +
# Example 1: Capitalize a Sentence

string = "python is AWesome."

capitalized_string = string.capitalize()

print('Old String: ', string)
print('Capitalized String:', capitalized_string)

# +
# Example 2: Non-alphabetic First Character

string = "+ is an operator."

new_string = string.capitalize()

print('Old String:', string)
print('New String:', new_string)
# -



StarcoderdataJupyterScriptsDedupFiltered