This post will discuss how to check if a string is empty in Python.

1. Using == operator

A simple solution is to use the == operator to compare the given string with an empty string.

Download  Run Code

 
Alternatively, you may use the != operator to check for a non-empty string:

Download  Run Code

2. Using not operator

The Pythonic way to check for an empty string is with the not operator as follows:

Download  Run Code

 
To check for non-empty string, you may do:

Download  Run Code

3. Using len() function

Finally, you may use the len() function to check for an empty string that returns the length of a string.

Download  Run Code

 
To check for non-empty strings, you can do:

Download  Run Code

That’s all about determining whether a string is empty in Python.