Lesson 14 – NoneType

When a Variable Has No Value

Sometimes in programming, we create a variable before we know what its value will be.

For example, in World of Software Engineering, a player might not currently have an enemy selected.

We can represent “nothing” using a special value called None.
Here is how we create an empty variable:

enemy = None
This does NOT mean the word "None".
It means the variable currently has no value assigned.
Important difference:

enemy = None
This is a real None-type value.

enemy = "None"
This is just text that says “None”.

They are completely different things.
Why does this matter?

Programs often check if something exists before using it.

For example:
print(enemy is None)
This will return True if enemy is empty.
Your Task:

Create a variable called enemy and set it to None.

Do not modify the print statement.
Create an empty variable
# create the empty "enemy" variable here


# don't edit anything under this comment line
print(enemy is None)