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 - In Python, empty strings are treated as "Falsy". So, we can use this for checking if a string is empty or not.
🌐
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 - We'll use an or operator to check both conditions at once: s = "" # Try also with s = None if s is None or s == "": print("String is empty or None") else: print("String is not empty and not None") Advice: Find out more about the or operator in Python by reading our "Guide to the Python or Operator".
🌐
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 - In Python, empty strings are considered equivalent to False for boolean operations. Therefore, we can use not to check whether a string is empty: if not my_string: print("my_string is empty!") else: print("my_string is not empty!")
🌐
Better Stack
betterstack.com › community › questions › how-to-check-if-string-is-empty-in-python
How to check if the string is empty in Python? | Better Stack Community
February 3, 2023 - To check if a string is empty in Python, you can use the len() function. For example: ... Alternatively, you can use the bool() function to check if the string is empty. An empty string is considered to be False, and all other strings are considered ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › python › check if string is empty or not in python
Check if String is Empty or Not in Python - Spark By {Examples}
May 21, 2024 - How to check if the Python String is empty or not? In python, there are several ways to check if the string is empty or not. Empty strings are considered
🌐
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 ...
🌐
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 - To check if the string is empty in Python, we shall be implementing the len() method in Python. As the string with whitespace is not considered empty, it will give a numerical value for the number of whitespaces that have been used in the string.
Find elsewhere
🌐
Squash
squash.io › how-to-check-for-an-empty-string-in-python
How to Check for an Empty String in Python - Squash Labs
We use an if-else statement with the not operator to check if string is empty. If it is, we print "The string is empty"; otherwise, we print "The string is not empty". Related Article: Python Command Line Arguments: How to Use Them
🌐
datagy
datagy.io › home › python posts › python strings › how to check if a string is empty in python
How to Check if a String is Empty in Python • datagy
December 16, 2022 - The simplest, and most Pythonic, way of checking if a string is empty in Python is to simply use an if-else block with the not keyword.
🌐
AskPython
askpython.com › home › 4 methods to check whether a string is empty in python
4 Methods to Check Whether a String Is Empty in Python - AskPython
February 27, 2022 - str1 = "" str2 = " " if(not str1): print ("Yes the string is empty") else : print ("No the string is not empty") if(not str2): print ("Yes the string is empty") else : print ("No the string is not empty" ...
🌐
Netjstech
netjstech.com › 2019 › 07 › check-string-empty-or-not-python.html
Check String Empty or Not in Python | Tech Tutorials
October 26, 2025 - Here note that String with only whitespaces is not considered false so you need to strip whitespaces before testing for such strings. def check_if_empty(string): if not string.strip(): print('empty String') str1 = "" check_if_empty(str1) str2 = " " check_if_empty(str2)
🌐
Tutor Python
tutorpython.com › check-if-string-is-empty-in-python
How to Handle or Check if String is empty in Python
December 25, 2023 - Let’s delve into this technique with a concise Python code example: my_string = "" if len(my_string) == 0: print("The string is empty") else: print("The string is not empty") The check for emptiness we use the character count.
🌐
TutorialsPoint
tutorialspoint.com › article › What-is-the-most-elegant-way-to-check-if-the-string-is-empty-in-Python
What is the most elegant way to check if the string is empty in Python?
April 21, 2025 - my_string = "" if not my_string: print("The string is empty") else: print("The string is not empty") ... The Python len() function returns the number of characters in a string.
🌐
PythonHello
pythonhello.com › problems › string › how-to-check-if-string-is-empty
Checking if a string is empty in Python
The len() function returns the length of a string, which can be used to check if the string is empty. An empty string has a length of 0, so if the length of the string is 0, it is considered empty. ... string = "" if len(string) == 0: print("The string is empty") else: print("The string is not empty")...
🌐
Quora
quora.com › Does-Python-have-something-like-an-empty-string-variable-where-you-can-do-if-myString-string-empty-Regardless-whats-the-most-elegant-way-to-check-for-empty-string-values
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? - Quora
You can use this to check if a string is empty or not. Strip away whitespace first so that if the string only contains whitespace, they’ll be removed and the string will be null, evaluating to False. You can remove the strip() method if you don’t want strings with only whitespace to be considered Empty. ... Note: Be explicit and use bool() in the function if you also need to pass stuff other than strings to the function. ... How do you write a Python ...
🌐
LabEx
labex.io › tutorials › python-how-to-check-if-a-string-is-not-empty-in-python-559579
How to Check If a String Is Not Empty in Python | LabEx
The lab guides you through creating a Python file named string_check.py and using boolean evaluation (if string1:) and the len() function (if len(string1) > 0:) to determine whether a string contains at least one character. You will execute the script to observe the output, demonstrating how Python identifies non-empty and empty strings using both approaches.
🌐
Python Pool
pythonpool.com › home › blog › 7 quick ways to check if string is empty in python
7 Quick Ways to Check If String is Empty in Python - Python Pool
May 4, 2023 - Not operator is used to perform the same task as of len() function. The empty string is always equivalent to False in Python. If we want to check if the string is empty or not, we can check it with the help of not operator.
🌐
Python Examples
pythonexamples.org › python-check-if-string-is-empty
Python - How to check if string is Empty?
Python - Check if String is Empty - To check if given string is empty, you can either use the string variable as is inplace a condition along with not operator, or verify if the string equals empty string "" using equal to operator.
🌐
Syntx Scenarios
syntaxscenarios.com › home › python › how to check if a string is empty in python?
How to Check if a String is Empty in Python?
September 24, 2025 - An empty string is considered False in Python. This allows you to directly check if a string is empty by simply evaluating its truth value using the not operator.