+ 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)
3 ответов
+ 6
if you take away return it outputs
0123456789
+ 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 .
+ 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)