Yandex

Python String lower() Method – Convert to Lowercase


Python String lower() Method

The lower() method in Python is used to convert all the characters in a string to lowercase. It's useful when comparing strings or working with user input where case sensitivity doesn't matter.

Syntax

string.lower()

Parameters:

  • None – This method does not take any arguments.

Returns:

  • A new string where all uppercase characters are converted to lowercase.

Example 1: Basic Usage

text = "HELLO WORLD"
print(text.lower())
hello world

Example 2: Mixed Case String

greeting = "GoOd MoRnInG"
print(greeting.lower())
good morning

Why Use lower()?

  • To make string comparison case-insensitive.
  • To clean up user input before storing or validating.
  • To normalize data for searching or sorting.

Example 3: Comparing Strings

a = "Python"
b = "PYTHON"
print(a.lower() == b.lower())
True

Even though the original strings differ in case, they are equal after using lower().

Does lower() Change the Original String?

No, strings in Python are immutable. The lower() method returns a new string — it doesn’t modify the original one.

Common Mistake

name = "ALICE"
name.lower()
print(name)
ALICE

Why? Because name.lower() returns a new string, but it wasn't assigned back to name.

Correct Way:

name = name.lower()
print(name)

Summary

  • lower() converts a string to lowercase.
  • Returns a new string — original is not changed.
  • Helps with case-insensitive comparisons and text cleaning.

Practice Problem

Ask the user to input a sentence and print it in lowercase.

text = input("Enter a sentence: ")
print("In lowercase:", text.lower())


Welcome to ProgramGuru

Sign up to start your journey with us

Support ProgramGuru.org

You can support this website with a contribution of your choice.

When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.

PayPal

UPI

PhonePe QR

MALLIKARJUNA M