Assuming ASCII strings:

string1 = 'Hello'
string2 = 'hello'

if string1.lower() == string2.lower():
    print("The strings are the same (case insensitive)")
else:
    print("The strings are NOT the same (case insensitive)")

As of Python 3.3, casefold() is a better alternative:

string1 = 'Hello'
string2 = 'hello'

if string1.casefold() == string2.casefold():
    print("The strings are the same (case insensitive)")
else:
    print("The strings are NOT the same (case insensitive)")

If you want a more comprehensive solution that handles more complex unicode comparisons, see other answers.

Answer from Harley Holcombe on Stack Overflow
Top answer
1 of 15
828

Assuming ASCII strings:

string1 = 'Hello'
string2 = 'hello'

if string1.lower() == string2.lower():
    print("The strings are the same (case insensitive)")
else:
    print("The strings are NOT the same (case insensitive)")

As of Python 3.3, casefold() is a better alternative:

string1 = 'Hello'
string2 = 'hello'

if string1.casefold() == string2.casefold():
    print("The strings are the same (case insensitive)")
else:
    print("The strings are NOT the same (case insensitive)")

If you want a more comprehensive solution that handles more complex unicode comparisons, see other answers.

2 of 15
741

Comparing strings in a case insensitive way seems trivial, but it's not. I will be using Python 3, since Python 2 is underdeveloped here.

The first thing to note is that case-removing conversions in Unicode aren't trivial. There is text for which text.lower() != text.upper().lower(), such as "ß":

>>> "ß".lower()
'ß'
>>> "ß".upper().lower()
'ss'

But let's say you wanted to caselessly compare "BUSSE" and "Buße". Heck, you probably also want to compare "BUSSE" and "BUẞE" equal - that's the newer capital form. The recommended way is to use casefold:

str.casefold()

Return a casefolded copy of the string. Casefolded strings may be used for caseless matching.

Casefolding is similar to lowercasing but more aggressive because it is intended to remove all case distinctions in a string. [...]

Do not just use lower. If casefold is not available, doing .upper().lower() helps (but only somewhat).

Then you should consider accents. If your font renderer is good, you probably think "ê" == "ê" - but it doesn't:

>>> "ê" == "ê"
False

This is because the accent on the latter is a combining character.

>>> import unicodedata
>>> [unicodedata.name(char) for char in "ê"]
['LATIN SMALL LETTER E WITH CIRCUMFLEX']
>>> [unicodedata.name(char) for char in "ê"]
['LATIN SMALL LETTER E', 'COMBINING CIRCUMFLEX ACCENT']

The simplest way to deal with this is unicodedata.normalize. You probably want to use NFKD normalization, but feel free to check the documentation. Then one does

>>> unicodedata.normalize("NFKD", "ê") == unicodedata.normalize("NFKD", "ê")
True

To finish up, here this is expressed in functions:

import unicodedata

def normalize_caseless(text):
    return unicodedata.normalize("NFKD", text.casefold())

def caseless_equal(left, right):
    return normalize_caseless(left) == normalize_caseless(right)
Discussions

Python allows you to compare strings, but it is not case sensitive. Mark true or false.
Find step-by-step Computer science solutions and the answer to the textbook question Python allows you to compare strings, but it is not case sensitive. Mark true or false.. More on quizlet.com
🌐 quizlet.com
1
Python allows you to compare strings, but it is not case sensitive.
Python allows you to compare strings, but it is not case sensitive. More on askfilo.com
🌐 askfilo.com
1
January 4, 2025
Python allows you to compare strings, but it not case sensitive in that comparison.Question 11 options: True False
Python allows you to compare strings, but it not case sensitive in that comparison. ... Here’s the best way to solve it. ... I'll work through this problem step by step. In Python, string comparison is done using comparison ...View the full answer More on chegg.com
🌐 chegg.com
1
February 16, 2024
Case sensitive string comparison
As far as I know, it is case sensitive by default. May be you mean case insensitive? Can you give an example and the code you tried? More on reddit.com
🌐 r/learnpython
6
2
January 22, 2021
🌐
LearnPython.com
learnpython.com › blog › python-case-sensitive
Is Python Case-Sensitive? | LearnPython.com
This is the most popular approach to case-insensitive string comparisons in Python. The lower() method converts all the characters in a string to the lowercase, making it easier to compare two strings.
🌐
GeeksforGeeks
geeksforgeeks.org › python › case-insensitive-string-comparison-in-python
Case-insensitive string comparison in Python - GeeksforGeeks
July 15, 2025 - If the set has only one unique element, it prints "equal" otherwise, "unequal". casefold() method in Python performs a case-insensitive comparison that accounts for locale-specific character differences.
🌐
LabEx
labex.io › tutorials › python-how-to-compare-two-python-strings-for-equality-in-a-case-insensitive-manner-395043
How to compare two Python strings for equality in a case-insensitive manner? | LabEx
Let's start by exploring how string comparisons work in Python and why case sensitivity matters. In Python, when you compare two strings using the equality operator (==), the comparison is case-sensitive by default.
🌐
iO Flood
ioflood.com › blog › using-python-to-compare-strings-methods-and-tips
Python String Comparison Methods | Quick User Guide
August 13, 2024 - In addition to these techniques, ... the == operator is used to compare string objects. Case sensitivity is a crucial aspect to consider when comparing strings in Python....
🌐
TutorialsPoint
tutorialspoint.com › how-do-i-do-a-case-insensitive-string-comparison-in-python
How do I do a case-insensitive string comparison in Python?
June 10, 2025 - In Python, string comparisons are case-sensitive by default. For example, when we consider the strings "Hello" and "hello" then they are considered as two different strings because of the difference in their letter casing.
Find elsewhere
🌐
Squash
squash.io › string-comparison-in-python-best-practices-and-techniques
String Comparison in Python: Best Practices and Techniques
May 21, 2024 - Note that string comparison in Python is case-sensitive, which means that uppercase letters are considered greater than lowercase letters.
🌐
Kanaries
docs.kanaries.net › topics › Python › is-python-case-sensitive
Is Python Case Sensitive? – Kanaries
August 18, 2023 - Python is a case-sensitive programming language, meaning it distinguishes between uppercase and lowercase characters. This feature allows for greater flexibility in creating variable names, functions, modules, classes, and constants. However, it also requires developers to be mindful of their ...
🌐
Brainly
brainly.com › english › high school › python allows you to compare strings, but it is not case sensitive. true or false
[FREE] Python allows you to compare strings, but it is not case sensitive. True or False - brainly.com
June 14, 2023 - Python is case sensitive when comparing strings, meaning that two strings with the same characters in different cases are not considered equal.
🌐
Replit
replit.com › home › discover › how to compare strings in python
How to compare strings in Python | Replit
April 14, 2026 - The comparison happens character by character based on their underlying Unicode values. For example, "apple" < "banana" is True because 'a' comes before 'b'. This comparison is case-sensitive.
🌐
DataWider
datawider.com › articles › python case insensitive string comparison: every method you need to know
Python Case Insensitive String Comparison: Every Method You Need to Know
May 7, 2026 - String comparison in Python is case-sensitive by default. "Hello" and "hello" are not equal as far as Python is concerned. But in most real applications, you don’t want that distinction to matter.
🌐
Medium
medium.com › @sami.hamdiapps › elevate-your-python-skills-string-comparison-python-made-easy-bd0b3b08b55b
Elevate Your Python Skills: String Comparison Python Made Easy | by Sami Hamdi | Medium
September 4, 2023 - At the core of Python string comparison Python are four operators: ==,!=, = and >=. These allow you to compare strings based on their lexicographic order — effectively alphabetic order. ... Note that Python is case-sensitive when comparing strings.
🌐
Codefinity
codefinity.com › courses › v2 › cf552d00-2991-4d8d-bab2-82d8904406ce › 6457ac36-df42-4b04-9e0f-a66a3a4c7027 › 0863d4fb-233e-46a5-990c-911c9a1c6b4e
Learn Comparing Strings | Cross-Type Interactions
String comparisons in Python are case-sensitive by default. If user input may vary in capitalization or include extra spaces, normalize first, then compare.
🌐
Cherry Servers
cherryservers.com › home › blog › cloud computing › how to do string comparison in python [with examples]
How to do String Comparison in Python | Cherry Servers
November 7, 2025 - Those are: ... These operators ... as the result of the comparison. Character comparison is done based on their Unicode values, which makes the comparison operation case-sensitive......
🌐
TutorialsPoint
tutorialspoint.com › article › is-python-case-sensitive-or-case-insensitive
Is Python case-sensitive or case-insensitive?
March 26, 2026 - Python is case-sensitive, treating uppercase and lowercase letters as different characters. Use proper naming conventions and leverage .lower() or .upper() methods when you need case-insensitive string comparisons.
🌐
Delft Stack
delftstack.com › home › howto › python › case insensitive string comparison in python
How to Compare String Case Insensitive String in Python | Delft Stack
February 2, 2024 - There are three main methods used to carry out case insensitive string comparison in python which are lower(), upper() and casefold().