+ 1

Please tell me the solution with explanation.

What is the highest number output by this code? def print_nums(x): for i in range(x): print(i) return print_nums(10)

22nd Jul 2020, 4:26 PM
SUNROSE SHRESTHA
SUNROSE SHRESTHA - avatar
3 ответов
+ 6
if you take away return it outputs 0123456789
22nd Jul 2020, 4:29 PM
Fakhri Mrabet
Fakhri Mrabet - avatar
+ 2
Here first take 0 & return 0.Here doesn't affect any value in function call. It return always 0 because it has written only return .
22nd Jul 2020, 4:29 PM
Sâñtôsh
Sâñtôsh - avatar
+ 1
It print 0, then return executed so exit loop. If you are trying to print all 0-9, then ident return to match for statement, so move it out (it's in loop now). def print_nums(x): for i in range(x): print(i) return print_nums(10) #(or remove return will also works, no difference) def print_nums(x): for i in range(x): print(i) print_nums(10)
22nd Jul 2020, 4:48 PM
Jayakrishna 🇮🇳