0
foor loop problem
for i in range(10): for num in range(i): print(i,end=" ") print(/n) please explain me this code...
5 Respuestas
+ 3
I think indentation got messed up – put it in a script on sololearn playground and link it and check the indentation.
Also check the 2nd print statement – it will give an error
0
Look, this is what you expected?
https://code.sololearn.com/cYXM2NwUvLE1/?ref=app
0
for i in range(10) :
for num in range(i) :
print(i, end=" ")
print("")
Output :
1 1
2 2 2
3 3 3 3
4 4 4 4 4
5 5 5 5 5 5
6 6 6 6 6 6 6
7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8
9 9 9 9 9 9 9 9 9 9
0
That's true, i forgot to write range(i + 1) and
Output :
0
...