Empty strings are "falsy" (python 2 or python 3 reference), which means they are considered false in a Boolean context, so you can just do this:

if not myString:

This is the preferred way if you do not need to differentiate between an empty string and some other falsy value. To explicitly check for an empty string use the following:

if myString == "":

See the documentation on Truth Value Testing for other values that are false in Boolean contexts.

Answer from Andrew Clark on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-program-to-check-if-string-is-empty-or-not
Check if String is Empty or Not - Python - GeeksforGeeks
July 11, 2025 - Explanation: A simple equality check (s == "") determines if the string is empty. The len() function returns the length of a string so if the length is 0, it means that string is empty: ... The string is empty.
Discussions

How can I check if a string is empty in Python? - Ask a Question - TestMu AI (formerly LambdaTest) Community
How can I check if a string is empty in Python? Is there a built-in variable like string.empty that represents an empty string, allowing for a check like if myString == string.empty? If not, what is the most elegant way to check for an empty string without hardcoding "" each time? More on community.testmuai.com
🌐 community.testmuai.com
0
June 26, 2024
Python: String empty or null?
Hey guys, one maybe very easy question: I try to check if a string item is empty, therefore I try it with: if len(ir.getItem(presenceLightAlter).state.StringValue()) > 0: But I get an error, because the item state is NULL and so there is no string value. How can I check both, if it is NULL or empty? More on community.openhab.org
🌐 community.openhab.org
4
0
February 25, 2021
What's the most pythonic way of checking if variable is None or empty string ""?
Both None and "" are falsy values so simply if not variable: will cover both those cases. This doesn't explicitly check for those values but if you're just checking for something not being set this is probably the way to go. More on reddit.com
🌐 r/learnpython
9
4
July 6, 2021
Python not recognizing an empty string ('') as an empty string
Firstly, I would strongly suggest avoiding phrasing like "Python not recognizing '' as empty string", since that's highly unlikely and it's probably just a bug in your program or unexpected data type in your data. It's never a compiler error, as they say. Be willing to accept you have a bug. You've provided the output of your code, but can you provide the code itself? After all, in your output it clearly looks like empty strings, but that's your output and not necessarily a source of truth. That would be the code + sample data. My debug approach for this would be to add more print statements. Check the type() of the variable you're concerned with. Print its len(). And repr(). Litter the area surrounding your if-statement with prints to understand exactly every choice that Python is making. Sometimes, I'll take the condition from an if and say print(variable == '') so that I can see the False for myself. Especially in the case of and/or conditions so I can make sure each piece is correct. One last note, [] is a list, not a dict. Dicts are {key: value}. More on reddit.com
🌐 r/learnpython
5
0
February 22, 2020
🌐
PythonHow
pythonhow.com › how › check-if-a-string-is-empty
Here is how to check if a string is empty in Python
my_string = "" if len(my_string) == 0: print("String is empty.")Another alternative would be to use the bool() function. This will check if the string is empty or not, returning True if it's empty and False if it's not. my_string = "" if not bool(my_string): print("String is empty.") ... Solve ...
🌐
Sentry
sentry.io › sentry answers › python › check if a string is empty in python
Python Truth Value Testing for Empty String Checks | Sentry
2 weeks ago - Check if a Python string is empty using truth value testing with the not operator, strict comparison with == "", or strip() to handle whitespace-only strings
🌐
Quora
quora.com › How-do-I-check-if-the-string-is-empty-in-Python
How to check if the string is empty in Python - Quora
Answer (1 of 15): You can check it with a very simple if execution. Let us say, if you want to check pure empty string (must not contain even whitespaces), then you can do just like below: [code]if not string: print("Empty") [/code]Or, if you want to consider string with no character (but may ...
Find elsewhere
🌐
Stack Abuse
stackabuse.com › how-to-check-if-a-string-is-empty-or-none-in-python
How to Check if a String is Empty or None in Python
June 5, 2023 - In Python, values are considered "truthy" or "falsy" based on whether they evaluate to True or False in a boolean context. This concept plays a crucial role when checking conditions in code. For strings, an empty string ("") is considered "falsy" — it evaluates to False in a boolean context.
🌐
Wyzant
wyzant.com › resources › ask an expert
Most elegant way to check if the string is empty in Python? | Wyzant Ask An Expert
May 22, 2019 - Does Python have something like an empty string variable where you can do: if myString == string.empty:Regardless, what's the most elegant way to check for empty string values? I find hard coding `""` every time for checking an empty string not as good. ... John L. answered • 05/24/19 ... All Python types have the ability to be evaluated for "truthiness," which is returned by the built-in Boolean conversion function, bool().
🌐
Programming Idioms
programming-idioms.org › idiom › 110 › check-if-string-is-blank › 1455 › python
Check if string is blank, in Python
#include <algorithm> #include <cctype> #include <string> bool blank = false; if (s.empty() || std::all_of(s.begin(), s.end(), [](char c){return std::isspace(c);})) { blank = true; }
🌐
Esri Community
community.esri.com › t5 › python-questions › quot-if-not-null-and-not-empty-string-quot-paradox › td-p › 1618009
Solved: "If not Null and not empty string" paradox - help ... - Esri Community
May 29, 2025 - From 6. Expressions - Python 3.y.z documentation: In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: False, None, numeric zero of all types, and empty strings and containers (including strings, tuples, lists, dictionaries, sets and frozensets). The issue isn't that your logic is incorrect, or that the code is incorrect (although it may be), it is that you are trying to interpret results for Python logical expressions as if they were SQL logical expressions.
🌐
Sololearn
sololearn.com › en › Discuss › 1779570 › is-an-empty-string-true-or-false-in-python-3
Is an empty string true or false in python 3
December 4, 2023 - Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.6 documentation
Split the string at the last occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return a 3-tuple containing two empty strings, followed by the string itself.
🌐
Data Science Parichay
datascienceparichay.com › home › blog › python – check if string is empty – with examples
Python - Check If String Is Empty - With Examples - Data Science Parichay
January 20, 2022 - # create two strings - s1 empty ... empty string is zero. You can use the Python len() function to calculate the length of the string and then compare it with zero to check if it is empty or not....
🌐
TestMu AI
community.testmuai.com › ask a question
How can I check if a string is empty in Python? - Ask a Question - TestMu AI (formerly LambdaTest) Community
June 26, 2024 - How can I check if a string is empty in Python? Is there a built-in variable like string.empty that represents an empty string, allowing for a check like if myString == string.empty? If not, what is the most elegant way to check for an empty string without hardcoding "" each time?
🌐
Replit
replit.com › discover › how-to-declare-empty-string-in-python
Discover | Replit
Build and deploy software collaboratively with the power of AI without spending a second on setup.
🌐
openHAB Community
community.openhab.org › setup, configuration and use › scripts & rules
Python: String empty or null? - Scripts & Rules - openHAB Community
February 25, 2021 - Hey guys, one maybe very easy question: I try to check if a string item is empty, therefore I try it with: if len(ir.getItem(presenceLightAlter).state.StringValue()) > 0: But I get an error, because the item state is…
🌐
Python Guides
pythonguides.com › check-if-a-variable-is-an-empty-string-in-python
Python Check If Variable Is Empty String
November 24, 2025 - Another easy method is to directly compare your variable against an empty string literal "". This is often used by beginners because it reads exactly like an English sentence. While it is slightly less “Pythonic” than the not operator, it is technically precise. It ensures you are comparing against a string and not just any falsy object like 0 or None. In this example, we check a variable representing a Social Security Number (SSN) input.
🌐
Scaler
scaler.com › home › topics › program to check if string is empty in python
Program to Check if String is Empty in Python - Scaler Topics
January 11, 2023 - Well as we move along the article we shall learn how to perform different operations on strings. Be it the len() method or the not operator where it considers the whitespace as an element of the string. As strings in Python cannot be modified once they’re created, hence it is useful to check ...
🌐
JanBask Training
janbasktraining.com › community › python-python › most-elegant-way-to-check-if-the-string-is-empty-in-python
Most elegant way to check if the string is empty in Python? | JanBask Training Community
March 9, 2021 - I find hard coding "" every time for checking an empty string not as good. ... In Boolean context, sequences are evaluated either as FALSE or TRUE and empty strings are considered as false. To solve the error “python string is empty” you can simply check if the string is false using: