0
In what condition a python programming displays "None " . Sometimes it is also getting displayed while executing a function .
Now-a-days , I am facing this issue .. Can anybody explain it using a small example where this issue happens !
9 Réponses
+ 3
It happens when a function doesn't return anything and you print it's return value .
Example:
https://code.sololearn.com/c9Eud8qs4xoX/?ref=app
+ 1
Thanks mate ! The future is now thanks to science[LESS ACTIVE]
+ 1
Ok thanks a lot !!
+ 1
def some_function():
print(“Hello from the function”)
print(some_function())
output:
Hello from the function
None
+ 1
def some_function():
return “Hello by the function”
print(some_function())
output:
Hello by the function
+ 1
def some_function():
print(“Hello from the function”)
some_function()
output:
Hello from the function
+ 1
def some_function():
return “Hello by the function”
some_function()
output:
0
Suppose we have a condition
where we shouldn't return the value in a function ! and we should avoid the none to get printed then what we should do ?
It is possible ?
The future is now thanks to science[LESS ACTIVE]
0
Then just call the function don't need to print the output from it.
for example,
hello()
here it will call only the hello function and won't print none.