+ 6

What is the meaning of None in python?

1st May 2017, 4:22 AM
Vishal Ramprasad
Vishal Ramprasad - avatar
3 ответов
+ 11
This is used to represent a variable that has no value or type to it. Even though var = 0 or var = "" may look like a representation of nothing, they still are something. var = 0 is still an integer (which is zero) var = "" is still a string (just a blank one) var = None however has no type. It's not an integer, float, string, or anything (It's officially called a "NoneType").
8th Jul 2017, 5:49 AM
Robert Hensley
Robert Hensley - avatar
+ 4
Robert explained it perfect. But You can do a test in python console: 1) Test for string: a = " " if a == None: print('It is None') else: print('It is NOT NONE, I am still string, but empty') 2) Test for int: b = 0 if b == None: print('Im None') else: print('Im int and I have a value 0!') 3) test with type() function, example: list = [] str = "abc" n = 0 nothing = None print(type(list)) print(type(str)) print(type(n)) print(type(nothing))
5th May 2017, 5:38 PM
Tommy L
Tommy L - avatar
+ 1
None is similar to null which we use in most of the programming languages.
1st Jul 2017, 7:04 PM
Kalluru Prasanna Sai Surya Narayana
Kalluru Prasanna Sai Surya Narayana - avatar