0
Can you please explain me the whole process of the output?
num=[1,3,5,6] for i in num: for c in range (i): print (c)
1 Resposta
+ 1
for i in num : #list value are taken into i in each iteration one after other, so for first iteration, i = 1, next 3, next 5, next 6
Inner loop
i=1
for c in range(i) : #means 0 to i-1 times iterates, I not inclusive. So
c=0 to i-1=0
Print 0
i=3:
c= 0 to 3-1=2
prints 0, 1, 2 #separelate lines.
i=5
c=0 to 5-1=4
Prints 0,1,2,3,4
i=6
c=0 to 6-1= 5
Prints 0,1,2,3,4,5
Output: #each value printed in separate lines but for your convenience, final output:
0
0 1 2
0 1 2 3 4
0 1 2 3 4 5