0

Please explain the working of below code as i am not able to understand

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

24th Apr 2020, 4:34 PM
ADITYA VENKATARAMAN
ADITYA VENKATARAMAN - avatar
2 ответов
+ 5
The return function is inside the for loop. The loop only executes once, (printing 0) and exits cos of the return statement. if the return statement were outside the for loop it'll print numbers in the range 0-9
24th Apr 2020, 4:40 PM
Justus
Justus - avatar
+ 1
Thank you !
24th Apr 2020, 4:44 PM
ADITYA VENKATARAMAN
ADITYA VENKATARAMAN - avatar