You should convert your current_users into a lowercase set and then do blazignly fast comparisons for each of your new users, just lowercased, e.g.:

current_users = ["John", "Admin", "Jack", "Ana", "Natalie"]
new_users = ["Pablo", "Donald", "Calvin", "Natalie", "Emma"]

current_users_lookup = {user.lower() for user in current_users}
for user in new_users:
    if user.lower() in current_users_lookup:
        print("Username {} unavailable.".format(user))
    else:
        print("Username {} available.".format(user))

Which would get you:

Username Pablo available.
Username Donald available.
Username Calvin available.
Username Natalie unavailable.
Username Emma available.
Answer from zwer on Stack Overflow
🌐
Reddit
reddit.com › r/learnprogramming › need help with case insensitive list comparison in python
r/learnprogramming on Reddit: Need help with case insensitive list comparison in Python
August 26, 2019 -

Hi all,

I'm learning python and have been trying to figure out how to properly compare lists for case insensitivity. If I have two lists, where the first list contains the current user names and the second list is a list of new usernames, how do I get to make sure that if a new user name John won't conflict with a username in the current users of JoHn or JOHN and vice versa?

I have this so far:

current_users = ['John', 'BiLl', 'simcitizzon', 'mIke', 'cHarlie', 'admin']

new_users = ['john', 'simcitiZzon', 'ralphwiggum', 'cherrymcsperry', 'sweettooth347']

for user in new_users:
    if user in current_users:
	    print("Sorry, " + user + " is taken.")
    else:
	    print(user + ", this username is available")
OrdinalIgnoreCase equivalent? Jul 23, 2025
r/learnpython
last yr.
Are If statement values case sensitive? Aug 23, 2022
r/learnpython
4y ago
help with IGNORECASE Oct 31, 2022
r/learnpython
3y ago
Case insensitive using startswith May 13, 2020
r/learnpython
6y ago
More results from reddit.com
🌐
Reddit
reddit.com › r/learnprogramming › python question: comparing lists, case insensitive
r/learnprogramming on Reddit: python question: comparing lists, case insensitive
August 2, 2017 -

Hi everyone, I am just starting to learn how to code, running into a problem when I try to compare two lists, my code is below:

current_users = ['May', 'April', 'Wu', 'Su', 'Lulu'] new_users = ['may', 'mike', 'jones', 'chow', 'paul'] for new_user in new_users: if new_user in current_users: print('username '+new_user+' is not available.') else: print('welcome')

when I try to make the current_users list case insensitive for comparing, I used:

current_users.lower() ==['may', 'april', 'wu', 'su', 'lulu']

when I run the code, result in a violation, stated that list can not have contribute .lower().

Is there anyway to make the list case insensitive?

thanks in advance.

🌐
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.
🌐
Softhints
softhints.com › ptkhonython
Python 3 compare two list case insensitive - Softhints
October 1, 2018 - To compare two lists in Python is easy with build in functions or list comprehensions. The more difficult problems is to compare two lists case insensitive. In this article you can find 3 examples. The first example is finding the missing elements between two list without taking into account the
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)
Find elsewhere
🌐
thisPointer
thispointer.com › home › python › python : how to compare strings ? | ignore case | regex | is vs == operator
Python : How to Compare Strings ? | Ignore case | regex | is vs == operator - thisPointer
January 11, 2022 - In this article we will discuss different ways to compare strings in python like, using == operator (with or without ignoring case) or using is operator or using regex.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-check-if-string-is-in-list-case-insensitive
Check if List contains a String case-insensitive in Python | bobbyhadz
Copied!my_list = ['BOBBY', 'HADZ', ... member of l, otherwise it evaluates to False. Both strings have to either be lowercase or uppercase to perform a case-insensitive comparison....
🌐
LearnPython.com
learnpython.com › blog › python-case-sensitive
Is Python Case-Sensitive? | LearnPython.com
Using the casefold() method is the strongest and the most aggressive approach to string comparison in Python. It’s similar to lower(), but it removes all case distinctions in strings.
🌐
Stack Overflow
stackoverflow.com › questions › 73389687 › case-insensitive-multiple-list-to-column-comparison
python - Case-insensitive multiple list to column comparison - Stack Overflow
Is there a way to make this comparison list insensitive without changing all the values to lower or upper? ... You can make a case-insensitive comparison without modifying df_test nor valid by replacing this line in your code:
🌐
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 - normal_str1 = "Hello World ß!" casefold_str1 = normal_str1.casefold() normal_str2 = "Hello World ss!" casefold_str2 = normal_str2.casefold() if casefold_str1 == casefold_str2: print("Both variables are equal") else: print("Both variables are not equal") ... Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe ... Maisam is a highly skilled and motivated Data Scientist. He has over 4 years of experience with Python programming language.
🌐
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 - str1 = "Tutorialspoint" str2 = "TUTORIALSPOINT" if str1.upper() == str2.upper(): print("The strings are equal i.e., case-insensitive") else: print("The strings are not equal") ... The casefold() method in Python is similar to the lower() method, ...
🌐
Stack Overflow
stackoverflow.com › questions › 64239191 › in-python-how-comparison-of-two-list-we-can-make-case-insensitive
for loop - in python how comparison of two list, we can make case insensitive? - Stack Overflow
October 7, 2020 - A more robust approach, in my opinion is to use case-folding as it'll be useful for comparing names which aren't necessarily plane Indian names.