Python lower() Function: Convert String to Lowercase

In Python, the lower() function is used to convert all characters in a string to lowercase letters. Below is a detailed explanation of the lower() function.

  1. Syntax: str.lower()
  2. Parameter: lower() is a method of the string object (str) and does not require any additional parameters.
  3. Return value: A new string is returned, where all characters from the original string are converted to lowercase.
  4. text = “Hello, World!”
    modified_text = text.lower()
    print(modified_text)

    Output:
    hello, world!

By using the lower() method, you can easily convert all characters in a string to lowercase, which is useful for ignoring case when comparing strings or normalizing string inputs.

bannerAds