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 know that your variable is a string. If your variable could also be some other type then you should use:

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
🌐
Jeremy Morgan
jeremymorgan.com › python › how-to-create-an-empty-string-in-python
How to Create an Empty String in Python
This approach creates an empty string by enclosing nothing between two sets of double quotes. This is the most common method for creating an empty string in Python.
🌐
Python.org
discuss.python.org › python help
.Empty string comprehension? - Python Help - Discussions on Python.org
March 14, 2020 - Hello everyone , I wrote this code ... return person a = person_infos('fna', 'lna', age=34) print(a) The variable age in the function definition is an empty string , but we when set age as a number ( age = 4 ) no error happens , when we say ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › initialize-empty-string-in-python
Initialize empty string in Python - GeeksforGeeks
July 23, 2025 - The simplest way to define an empty string is by using two quotation marks with nothing in between. These can be single (') or double (") quotes. Both are valid. ... You can also use Python’s built-in str() function to create an empty string.
🌐
Stanford
web.stanford.edu › class › archive › cs › cs106a › cs106a.1204 › handouts › py-string.html
Python Strings
>>> s = 'Python' >>> len(s) 6 >>> len('') # empty string 0 · The formal name of the string type is "str". The str() function serves to convert many values to a string form.
🌐
Enterprise DNA
blog.enterprisedna.co › python-empty-string
Python Empty String: Explained With Examples – Master Data Skills + AI
The format() method in Python is a string method that formats specified values in a string. You can use it with a literal blank string, as in this code snippet: ... You have several choices for identifying an empty string with Python code.
🌐
TutorialsPoint
tutorialspoint.com › 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?
Let's look at the following example, where we are going to use the basic way to check whether the string is empty or not. str1 = "" if not str1: print("It Is Empty.") else: print("It Is Not Empty.") ... The string is empty. The Python len() function is used to determine the length of an object ...
Find elsewhere
🌐
EyeHunts
tutorial.eyehunts.com › home › what is python empty string | example code
What is Python empty string | Example code - EyeHunts
July 21, 2021 - Python string is called an empty string if the string doesn't have any character, whitespace whatsoever. But if the string has multiple white
🌐
GeeksforGeeks
geeksforgeeks.org › python-program-to-check-if-string-is-empty-or-not
Check if String is Empty or Not - Python - GeeksforGeeks
April 12, 2025 - 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. ... If len(s) == 0 then the string is empty. In Python, empty strings are treated as "Falsy".
🌐
Reddit
reddit.com › r/learnpython › meaning of empty string "" in this example
r/learnpython on Reddit: Meaning of empty string "" in this example
November 6, 2022 -
import random

def shuffle(string):
    templist = list(string)
    random.shuffle(templist)
    return "".join(templist)

usablelower = chr(random.randint(97, 122))
usableupper = chr(random.randint(65, 90))
usablenum = chr(random.randint(48, 57))

rst = random.choice(usableupper)
rst1 = random.choice(usablelower)
rst2 = random.choice(usablenum)
pw = rst1 + rst + rst2 + rst + rst2 + rst1
pw = shuffle(pw)
print(pw)

Hello, I was trying to code a random password generator yet I could not understand the "return "".join(templist)" part. What is the use of empty string here, what does it do and why this code require it?

🌐
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 - To get semantics out of the way, ... Pythonic, way of checking if a string is empty in Python is to simply use an if-else block with the not keyword....
🌐
Rosetta Code
rosettacode.org › wiki › Empty_string
Empty string - Rosetta Code
3 weeks ago - Checking if a string is empty is simple, just count the number of characters before you reach the terminator. If that count equals zero, the string is empty. Otherwise, the string is not empty.
🌐
Syntax Scenarios
syntaxscenarios.com › python › check-if-a-string-is-empty
How to Check if a String is Empty in Python? – Syntax Scenarios
Imagine a box that can hold letters or numbers. If the box is empty, it doesn’t have anything inside. Similarly, an empty string means no characters are present, not even a space. In Python, it’s written as two quotes with nothing in between: "".
🌐
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
string = " " if not string.strip(): print("The string is empty or consists only of whitespace characters") ... This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Convert bytes to a string in Python and vice versa?
🌐
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
Answer (1 of 3): I would test noneness before stripping. Also, I would use the fact that empty strings are False (or Falsy). This approach is similar to Apache's StringUtils.isBlank or Guava's Strings.isNullOrEmpty This is what I would use to test if a string is either None OR Empty OR Blank: [...
🌐
Studytonight
studytonight.com › post › how-to-check-for-an-empty-string
How to check if string is empty in Python? - Studytonight
May 3, 2023 - We saw in this article how to verify an empty string in Python using the len() function, comparing it to an empty string literal, and using the string's boolean value. We also looked at how to use the string function isspace to check for spaces( ). If you believe we overlooked something or have an alternative approach, please share it in the comments area below.