If not having a value has a meaning in your program (e.g. an optional value), you should use None. That's its purpose anyway.

If the value must be provided by the caller of __init__, I would recommend not to initialize it.

If "" makes sense as a default value, use it.

In Python the type is deduced from the usage. Hence, you can change the type by just assigning a value of another type.

>>> x = None
>>> print type(x)
<type 'NoneType'>
>>> x = "text"
>>> print type(x)
<type 'str'>
>>> x = 42
>>> print type(x)
<type 'int'>
Answer from wierob on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › initialize-empty-string-in-python
Initialize empty string in Python - GeeksforGeeks
July 23, 2025 - You can also use Python’s built-in str() function to create an empty string. This is useful when you want to ensure that the variable is always a string. ... Sometimes, we may want to initialize a string variable and leave it empty for now.
🌐
Jeremy Morgan
jeremymorgan.com › python › how-to-create-an-empty-string-in-python
How to Create an Empty String in Python
By making a call to str() which does not contain any arguments, this method creates an empty string. This is another way to initialize the variable without adding any data to it.
🌐
YouTube
youtube.com › case digital
How To Declare Empty String In Python - YouTube
In this python tutorial, we discuss how to declare empty string in python! We go over 2 methods you can use to declare empty strings in python! Let's start c...
Published   July 9, 2021
Views   1K
🌐
YouTube
youtube.com › watch
Python An Empty String - YouTube
Shows how to create an empty string and discusses the nature of such a string.
Published   September 23, 2014
🌐
Python
mail.python.org › pipermail › tutor › 2002-December › 019518.html
[Tutor] Declare empty string variable?
Whenever Python sees something like >>>myvariable = "a test" It creates the name "myvariable" in the current namespace if it is not already there and binds it to the Python object, a string in this case, "a test". Next time you use myvariable in some expression Python just sticks in "a test" automatically. As you see from my description variables are created on the fly, so to speak, no declarations are needed. So, to answer your question in a more direct manner you just do >>>dual = "" and voilá, you now have a dual variable initialized to the empty string.
🌐
TutorialKart
tutorialkart.com › python › python-create-an-empty-string
How to create an Empty String in Python?
April 3, 2023 - To create empty string using str(), call the function, and pass no arguments to the function, and it returns an empty string.
🌐
Python Examples
pythonexamples.org › python-create-empty-string
Creating an Empty String in Python: 3 Different Methods
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. ... In this tutorial of Python Examples, we learned how to create an empty string in different ways, with the help of well detailed ...
Find elsewhere
🌐
EyeHunts
tutorial.eyehunts.com › home › python initialize empty string | example code
Python initialize empty string | Example code - EyeHunts
December 1, 2021 - To initialize an empty string in Python, Just create a variable and don't assign any character or even no space. This means assign "" to a
🌐
YouTube
youtube.com › watch
Python Empty Strings Explained: 5 Simple Methods & When to Use Them - YouTube
Struggling to create empty strings in Python? This tutorial breaks down 5 easy methods (like quotes, str(), chr(), and more!) and reveals practical use cases...
Published   June 7, 2024
🌐
Rosetta Code
rosettacode.org › wiki › Empty_string
Empty string - Rosetta Code
1 week ago - IDENTIFICATION DIVISION. PROGRAM-ID. EMPTYSTR. DATA DIVISION. WORKING-STORAGE SECTION. 01 str PIC X(10). PROCEDURE DIVISION. Begin. * * Assign an empty string. INITIALIZE str. * * Or MOVE " " TO str. IF (str = " ") DISPLAY "String is empty" ELSE DISPLAY "String is not empty" END-IF.
🌐
Codecademy
codecademy.com › forum_questions › 5194c9c37a57d7acad002a26
Possible to declare an empty string? | Codecademy
Hi there, just curious about being able to declare a string variable that has no value assigned to it but is ready to be used. Is it possible? And how would Python know what sort of variable it is since, from my experience, the type of variable is decided when the variable is defined? Or would that happen when you do assign a value to the variable? For eg. would my_name = None be an empty string ready for use at a later stage?
🌐
Python Forum
python-forum.io › thread-17542.html
Use range to add char. to empty string
This seems simple enough, but I can't seem to get my head around it. The problem: Create an empty string and assign it to the variable lett. Then using range, write code such that when your code is run, lett has 7 b’s ('bbbbbbb'). My attempt: let...
🌐
Reddit
reddit.com › r/learnpython › is there a better way to make an empty string?
r/learnpython on Reddit: Is there a better way to make an empty string?
January 22, 2020 -

Total curiosity, but is there a way I can do this better:

player_inputs = ["", ""]

I want to have a list of 2 strings, but the strings will be inputed later. I thought I could do this:

player_inputs = [str, str]

but that doesn't work, not sure why.

Top answer
1 of 1
4
Hi Tabish Kazi, Without looking at the video, I can tell you that in the specific example given, the second code example would lead to the same result as the first code example. The real difference lies in the operator used. In the first example you use the plus-equal operator which reads the current value of the variable and adds the value to the right of the operator to it, then stores the new value to the variable. In the second example, the value to the right of the assignment operator is stored in the variable with no preference to what is already stored in the variable. The thing is though, in order for the plus-equal operator to work, the value of the variable can’t be null or undefined. So say you were looping through a series of properties and you wanted to dynamically create an HTML list item for each valid property without knowing how many list items would need to be created in advance. Well you know you’re going to wrap all this HTML within a string (and later set the innerHtml of some element to be equal to this string). And so you want to continually build upon this HTML string for however long the for loop runs. And so you decide to use the plus-equal operator to add to this string, but if the variable you’re adding to isn’t already a string, then the JS interpreter wouldn’t be able to add the first list item to it (a string of html defined declaratively). The program/code would crash. This is because the interpreter wouldn’t know how to add an undefined value and a string together (just as the interpreter wouldn’t know how to add something like a string and an integer together). So you initialize the variable as an empty string so that the interpreter knows that the variable is indeed a string, and as such, can be concatenated with other strings. I’m thinking that maybe I’ve over explained a bit, but I hope that makes sense. Let me know if it doesn’t.
🌐
Enterprise DNA
blog.enterprisedna.co › python-empty-string
Python Empty String: Explained With Examples – Master Data Skills + AI
Here is some sample code to demonstrate the assignment of empty strings to two string variables. ... The str() function is an in-built Python function.
🌐
Reddit
reddit.com › r/learnpython › how to initialize string type variable
r/learnpython on Reddit: How to initialize string type variable
January 9, 2024 -
# HINT: modify the headlines list to verify your loop works with different inputs

headlines = ["Local Bear Eaten by Man", "Legislature Announces New Laws", "Peasant Discovers Violence Inherent in System", "Cat Rescues Fireman Stuck in Tree", "Brave Knight Runs Away", "Papperbok Review: Totally Triffic"]

news_ticker = ""

write your loop here

n = 0 lenoftotal = 0 counter = 0

for n in headlines: counter = counter + 1 lenoftotal = lenoftotal + len(n) storedstring = storedstring + " " + headlines[n] if len(storedstring) == 140: break print(f"{storedstring}")

Output:

sentimental/ $ python mario.py

Traceback (most recent call last): File "/workspaces/23315992/sentimental/mario.py", line 18, in <module> storedstring = storedstring + " " + headlines[n] NameError: name 'storedstring' is not defined sentimental/ $

While initializing integer to 0 I can follow, not sure how to initialize a string type data and particularly storedstring in the above code.