⊕
⊖
Contents
Create an empty string
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 an empty string using single quotes
In the following program, we create an empty string using single quotes, and store the value in x.
Output
x :
2. Create an empty string using double quotes
In the following program, we create empty string using double quotes.
Output
x :
3. Create an 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.
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.
Next Topic ⫸ Python - Create string of specific length
⫷ Previous Topic Python - Create multiline string