why is the output of this code would be like that? i have executed the program in sololearn compiler but the output was strange. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

27th Jul 2022, 6:59 AM
Nariman Tajari
Nariman Tajari - avatar
4 Answers
+ 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..!!
27th Jul 2022, 10:32 AM
Jayakrishna 🇮🇳
0
ReferenceError: s is not defined That's the error message I get.
27th Jul 2022, 7:05 AM
Gordon
Gordon - avatar
0
may i ask you try it now Gordon ?
27th Jul 2022, 7:18 AM
Nariman Tajari
Nariman Tajari - avatar
0
Why you calling the function on assigning it to a variable do: S= hello Not: S = hello()
27th Jul 2022, 8:57 AM
Umar Farooq