Skip to content

What is Python empty string | Example code

  • by

Python string is called an empty string if the string doesn’t have any character, whitespace whatsoever. But if the string has multiple white spaces or single space or tab spaces then it is a blank string.

Example Create and check an empty string in Python.

Simple python example code. In a Boolean context, null / empty strings are false (Falsy). If you use

if not myString:

Code approach

# create empty string
a = ""

# check empty string
if not a:
    print("Empty String")
else:
    print(a)

Output:

Python empty string

Do comment if you have any doubts and suggestions on this python string topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading