Again about "return"!!😅😅 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Again about "return"!!😅😅

def func(x): for i in range(x): res+=1 return res print (func(4))

1st Nov 2017, 3:14 PM
Shyamal Bhatt
Shyamal Bhatt - avatar
2 Answers
+ 2
Because the range function starts from 0, and 0 is printed, then the return breaks the function.
1st Nov 2017, 3:24 PM
Boris Batinkov
Boris Batinkov - avatar
+ 1
def print_num(x): for i in range(x): print(i) return print_num(10) how the answer is “0”
1st Nov 2017, 3:17 PM
Shyamal Bhatt
Shyamal Bhatt - avatar