Create Empty String

To create an empty string in Python, we can use single or double quotes, or str() builtin function.

To create empty string using single or double quotes, provide the quotes and give no character in the quotes. That returns an empty string.

In the following code snippet, we create an empty string using single quotes and assign it to variable name.

</>
Copy
name = ''

In the following code snippet, we create an empty string using double quotes.

</>
Copy
name = ""

To create empty string using str(), call the function, and pass no arguments to the function, and it returns an empty string.

In the following code snippet, we create an empty string using str() builtin function.

</>
Copy
name = str()

Example

In the following program, we create empty strings using single quotes, double quotes, and str() builtin function.

main.py

</>
Copy
name1 = ''
print(f'name1 : {name1}')

name2 = ""
print(f'name2 : {name2}')

name3 = str()
print(f'name3 : {name3}')

Output

name1 : 
name2 : 
name3 :

Conclusion

In this Python Tutorial, we learned how to create an empty string in Python using single quotes, double quotes, or str() builtin function.