If you don't want to use str.lower(), you can use a regular expression:

import re

if re.search('mandy', 'Mandy Pande', re.IGNORECASE):
    # Is True
Answer from eumiro on Stack Overflow
🌐
Codecademy
codecademy.com › article › how-to-check-if-a-string-contains-a-substring-in-python
How to Check if a String Contains a Substring in Python | Codecademy
The substring is found! ... Python’s built-in .upper() method converts all characters of a string to uppercase. When performing case-insensitive string comparisons or searches, this can be quite useful as it eliminates inconsistency brought on by different capitalization in the strings.
Discussions

Perform Case Insentive Search
This code works and returns 5 lines before the string ‘JUMP’, but need to make the search case-insensitive. Best, Dave from collections import deque def search(lines, pattern, history=1): previous_lines = deque(maxlen=history) for line in lines: if pattern in line: yield line, previous_lines ... More on discuss.python.org
🌐 discuss.python.org
5
0
July 30, 2021
help with IGNORECASE
https://docs.python.org/3/library/stdtypes.html#str.startswith startswith doesn't take an "ignore case" parameter because there are no circumstances under which it will ignore case. More on reddit.com
🌐 r/learnpython
2
1
October 31, 2022
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
python - pandas "case insensitive" in a string or "case ignore" - Stack Overflow
Set it to False to do a case insensitive match. Copydf2 = df1['company_name'].str.contains("apple", na=False, case=False) ... Save this answer. ... Show activity on this post. If you want to do the exact match and with strip the search on both sides with case ignore, Copydf[df['Asset Name'].str.strip().str.match('searchstring'.strip(), case=False)] ... exact match? No, OP wants to check if their search string ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How do you check if a string contains a substring in Python?
Use substring in text. It returns True when the substring exists and False otherwise.
🌐
golinuxcloud.com
golinuxcloud.com › home › programming › python › check if string contains substring in python
Check if String Contains Substring in Python: in, find(), index(), ...
How can I check if a string contains a substring in Python?
In Python, you can check if a string contains a substring using several methods.
1. Use the in keyword, which returns True if the substring is present within the string.
2. Use str.find(), which returns the index of the first occurrence of the substring or -1 if not found.
3. Use str.index(), which raises an error if the substring is not found.
4. Use startswith() and endswith() to check if a string begins or ends with a specific substring.
🌐
metaschool.so
metaschool.so › home › software development › master string searches in python 2025
Master String Searches in Python 2025
How do you check if a string contains a substring case-insensitively?
Normalize both values the same way, for example substring.casefold() in text.casefold().
🌐
golinuxcloud.com
golinuxcloud.com › home › programming › python › check if string contains substring in python
Check if String Contains Substring in Python: in, find(), index(), ...
🌐
Metaschool
metaschool.so › home › software development › master string searches in python 2025
Master String Searches in Python 2025
February 7, 2025 - Yes, string containment checks in Python are case-sensitive by default. This means that the check will distinguish between uppercase and lowercase characters. For instance, checking if "hello" is in "Hello World" will return False because of ...
🌐
thisPointer
thispointer.com › home › python › python : check if a string contains a sub string & find it’s index | case insensitive
Python : Check if a String contains a sub string & find it's index | case insensitive - thisPointer
April 30, 2023 - mainStr = "This is a sample String with sample message." listOfstrs = ['sample', 'String', 'with'] # Check if all strings from the list exists in given string result = all(([True if subStr in mainStr else False for subStr in listOfstrs])) if result: print('All strings from list Found in main String ') ... We can also use python’s regex module to check if a given string exists in another string in both case sensitive and insensitive manner i.e.
🌐
GoLinuxCloud
golinuxcloud.com › home › programming › python › check if string contains substring in python
Check if String Contains Substring in Python: in, find(), index(), count(), and Regex
June 23, 2026 - ... Use exact casing when case matters, such as product codes, file extensions, or protocol names. Use lower() for simple ASCII-style checks. Use casefold() for more robust case-insensitive matching.
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python
Search for a String in Python (Check If a Substring Is Included/Get a Substring Position) | note.nkmk.me
May 7, 2023 - Extract a substring from a string in Python (position, regex) You can specify re.IGNORECASE as the flags argument of functions such as re.search() andre.findall() to search case-insensitive.
🌐
Real Python
realpython.com › lessons › exercise-check-case-insensitive-substring
Exercise: Check for a Case-Insensitive Substring – Real Python
Check if a Python String Contains a Substring (Overview) 02:00 · Confirm the Presence of a Substring 04:31 · Generalize Your Substring Check 04:10 · Exercise: Check for a Case-Insensitive Substring 08:00 · Find Out More About the Substring · Learn More Using String Methods 01:49 ·
🌐
iO Flood
ioflood.com › blog › python-string-contains
Python String Contains | Methods and Usage Examples
December 5, 2023 - This means that ‘Fun’ and ‘fun’ are considered different substrings. If you need to perform a case-insensitive check, make sure to convert both the string and the substring to the same case (either lower or upper) before performing the check.
🌐
Analytics Vidhya
analyticsvidhya.com › home › learn how to check if a string contains a substring in python
Learn How to Check If a String Contains a Substring in Python - Analytics Vidhya
January 10, 2024 - Case-insensitive substring found! To check if a string contains multiple substrings, you can use a loop or combine the ‘in’ operator with logical operators such as ‘and’ or ‘or’. Here’s an example: ... string = "Hello, World!" substrings = ["Hello", "Python"] if all(substring in string for substring in substrings): print("All substrings found!") else: print("One or more substrings not found.")
🌐
Mathspp
mathspp.com › blog › how-to-work-with-case-insensitive-strings
How to work with case-insensitive strings | mathspp
January 21, 2023 - To implement the class CaseInsensitiveSet, we will follow an approach that is very similar to the one employed above to implement a case-insensitive dictionary. We just need to be aware that an expression like value in set depends on the dunder method __contains__. We will inherit from the built-in set and we will override the methods that we are interested in. Then, we just need to use the string method str.casefold before deferring to the original methods that do value insertion/removal/membership testing.
🌐
Python Morsels
pythonmorsels.com › substring-check
Substrings in Python: checking if a string contains another string - Python Morsels
July 18, 2026 - If all you need is a simple substring check, use the in operator. >>> part = "Python" >>> whole = "I enjoy writing Python code." >>> part in whole True · If you need a case-insensitive containment check, use the string casefold method:
🌐
EyeHunts
tutorial.eyehunts.com › home › python string contains case insensitive | example code
Python string contains case insensitive | Example code
April 25, 2022 - str1 = "Messi is the best SoCceR player" if "soccer" in str1.lower(): print("Contain soccer") if "Player" in str1: print("Contain football") ... Answer: Make the string lowercase or uppercase before matching it. ... Do comment if you have any doubts or suggestions on this Python string topic.
🌐
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, but the difference is caseless matching, which is useful for comparing strings containing special characters or Unicode.
🌐
Python.org
discuss.python.org › python help
Perform Case Insentive Search - Python Help - Discussions on Python.org
July 30, 2021 - This code works and returns 5 lines before the string ‘JUMP’, but need to make the search case-insensitive. Best, Dave from collections import deque def search(lines, pattern, history=1): previous_lines = deque(maxlen=history) for line in lines: if pattern in line: yield line, previous_lines previous_lines.append(line) # Example use on a file if __name__ == '__main__': with open('test.txt') as f: for line, prevlines in search(f, 'JUMP', 5): ...
🌐
GeeksforGeeks
geeksforgeeks.org › case-insensitive-string-comparison-in-python
Case-insensitive string comparison in Python - GeeksforGeeks
April 22, 2025 - Explanation: This code uses casefold() for accurate case-insensitive comparison, especially with international characters. It converts all strings, checks uniqueness using a set and prints "equal" if all are identical otherwise, "unequal". re.match() checks if a string matches a pattern from the start and with the re.IGNORECASE flag, it ignores case differences.