+ 2

Pls explain it

I written a code in python But something is different I dont know how the result is coming Pls help https://code.sololearn.com/c2nDI79Nnvgj/?ref=app

8th Jan 2020, 9:39 AM
Anay Sah
Anay Sah - avatar
3 Respostas
+ 4
Nice question
23rd Jan 2020, 2:54 PM
Avinash
Avinash - avatar
+ 3
For r in range (10) print r which is 0 then print r which now 2 so 0 2 then it starts again from the beginning print r which is 1 now the print r which is 2 so 0 2 1 2 and so on.... It's like with each r you print print 2 next to it
8th Jan 2020, 10:15 AM
Pattern
Pattern - avatar
+ 2
For loop prints from 0 to 9 and r=2 is executed every time for every single loop. So you get- 0212223242...See how that 2 is coming after every digit from 0 to 9.
8th Jan 2020, 10:19 AM
Avinesh
Avinesh - avatar