+ 1

I don't understand this code

Why is the result 0? #what is the highest number output def a(x): for i in range(x): print(i) return a(10)

20th Aug 2017, 1:25 PM
The Crown
The Crown - avatar
2 Answers
+ 2
The return statement will end the function, so the loop only goes through the first iteration, only outputing the 0.
20th Aug 2017, 1:45 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thanks!
20th Aug 2017, 10:18 PM
The Crown
The Crown - avatar