0
Python
def print_nums(x): for i in range(x): print(i) return print_nums(10) I don't understand the code sequence. Can you help me?
6 odpowiedzi
+ 5
If you outdent 'return' to match the indentation of 'for', then the return (which you could leave out because now it does nothing) won't happen until the for loop is finished and the output is
0
1
2
3
4
5
6
7
8
9
+ 3
yeola
I tried to run this code in playground, but local internet is iffy tonight.
I am pretty sure that your output will be 0
The call of the definition specifies 10, but the specifics of the definition will only return 0
This is how it works
for i in range(10):
print(i) # 0
return # stops iteration
So the only output is 0
+ 2
def print_nums(x):
for i in range(x): print(i)
print_nums(10)
+ 2
<★Shaurya Chauhan★>(Inspiration will draw you)
I was just thinking the same thing
+ 1
I wanted to tell that there are 2 correct marked answers in sololearn how
Is there a bug 🐛🤔
Rik Wittkopp David Ashton
Your both answers are marked the best
0
Inicias una variable en (x) y luego declaras un ciclo que i es igual a x y imprime i y le asigna un vamos a la x de la variable