def greet(): print("hello") greet() greet() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

def greet(): print("hello") greet() greet()

The following program output is hello in 1000 times how its giving 1000 hello as i have called greet function only two times someone helpe me to understand this https://code.sololearn.com/c56QS4Oy48MA/?ref=app https://code.sololearn.com/c56QS4Oy48MA/?ref=app https://code.sololearn.com/c56QS4Oy48MA/?ref=app

24th Oct 2020, 1:47 PM
Jaya Pratha
Jaya Pratha - avatar
2 Answers
+ 3
That is an infinite recursive call. You are calling the function greet() inside itself. When you say greet() it will call the function and prints 'hello' but the next line is greet() again which again calls the same function and this goes on.
24th Oct 2020, 1:51 PM
Avinesh
Avinesh - avatar
+ 4
Remove the space which is before the first greet()
24th Oct 2020, 1:55 PM
你知道規則,我也是
你知道規則,我也是 - avatar