+ 1

Little bit confusing!!

def print_num(x): for i in range(x): print(i) return print_num(10) how the answer is “0”

2nd Nov 2017, 5:12 PM
Shyamal Bhatt
Shyamal Bhatt - avatar
2 odpowiedzi
+ 4
After return statement, the loop terminates as no code can be executed after return statement in its block. As the very first value of i was 0, so only 0 will be printed.
2nd Nov 2017, 5:31 PM
Lakshay
Lakshay - avatar
+ 1
function will exit when a return is called. remove return from inside the loop
2nd Nov 2017, 5:23 PM
Qwertiony
Qwertiony - avatar