0
why is the output of this code would be like that? i have executed the program in sololearn compiler but the output was strange.
def hello(): print ('hello world') s=hello() print(s) print ('ali') hello() print ('---') def hello_2(): return 'hello world2' s=hello_2() print(s) def hello_3(p): print(p) s='hello_world3' hello_3(s) ---------------------------------------- output: hello world hello_world3 ali hello world --- hello world2 hello_world3
4 ответов
+ 2
Save code and share link here,.,
Your hello() function have no return value so it returns none implicitly...
So
s=hello()
print(s) # output none
Not hello_world3
What is other strange you mean here.. Add your expected outout..!!
0
ReferenceError: s is not defined
That's the error message I get.
0
may i ask you try it now Gordon ?
0
Why you calling the function on assigning it to a variable do:
S= hello
Not:
S = hello()