Python – Create Empty String

Create String using str() Builtin Function

To create an empty string in Python, we can specify no value enclosed in the single quotes, no value enclosed in double quotes, or no argument passed to str() builtin function.

Examples

1. Create empty string using single quotes

In the following program, we create empty string using single quotes.

Python Program

x = ''
print('x :', x)
Run

Output

x : 

2. Create empty string using double quotes

In the following program, we create empty string using double quotes.

Python Program

x = ""
print('x :', x)
Run

Output

x : 

3. Create empty string using str()

In the following program, we create empty string using str() builtin function. Pass no value as argument to str() function. The function returns an empty string.

Python Program

x = str()
print('x :', x)
Run

Output

x : 

Summary

In this tutorial of Python Examples, we learned how to create an empty string in different ways, with the help of well detailed examples.