+ 4
Why a=0
When i writhen this code: a=print("hello") print(a) Python give me next output: Hello None Why in 2 line python give me None explain pls
3 Réponses
+ 14
It is because print() is a function that does NOT RETURN any value.
a = print( "Executed first" )
print( a )
>> Executed first
None
- - - - - - - - - - - - - - - - - - - - - -
This is just a representation of what's happening in the background (not the actual code of print function, just for representation) .
def print(text):
# some code to output in console
print("Hello World")
# The print() function does not return any value. Therefore None.
+ 2
Thanks
+ 1
You can try this to better understand......
print (print ('hello'))
#output : hello None



