** * This article is from Udemy "[Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style](https://www.udemy.com/course/python-beginner/" Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style ")" It is a class notebook for myself after taking the course of. It is open to the public with permission from the instructor Jun Sakai. ** **
◆None
In Python, an empty object is referred to as None
.
None
is_empty = None
if is_empty == None:
print('None!!!')
result
None!!!
Of course, you can use ==
to make a judgment as you have done so far,
It is rare to use ==
in the judgment of None.
None_is
is_empty = None
if is_empty is None:
print('None!!!')
result
None!!!
Keep in mind that ʻis` is often used to determine None.
==
and ʻis`=_is
print(1 == True)
print(1 is True)
result
True
False
The exact difference doesn't have to be known at this stage,
ʻIs is True when the left and right sides are exactly the same. Remember to use ʻis
because it is most often judged as None.
Recommended Posts