How to Create an Empty String in Python

Here are three ways to create an empty string in Python:

  1. Assign to a variable using “single or double quotes.”
  2. Using the “str()” function.
  3. Using the “format()” function of an empty string.

Method 1: Using single or double quotes

The quote(“”) is probably the most common and straightforward method to create an empty string. You can use single or double quotes.

Initialize a string containing no characters. This means assigning “” to a variable to initialize an empty string.

empty_string = ""

Print the empty string.




You can see that the output’s second line is empty, meaning it’s an empty string.

Method 2: Using the “str()” function

To create an empty string in Python, you can also use the “str()” function.

empty_string = str()




Method 3: Using the format() function

You can use the “format()” method to create an empty string in Python.

empty_string = "".format()



To check if the String is empty, use a “not operator”.

That’s it.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.