can any body help? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can any body help?

can any body explain this code? m=0 for x in range(1,4): for y in range(1,3): m=m+1 print (m)

30th Oct 2020, 12:38 PM
shahrbanoogolmohamadi
2 Answers
+ 3
Three times, do this twice: add m to itself + 1 then after all that, print m.
30th Oct 2020, 12:43 PM
Slick
Slick - avatar
+ 1
range(1,4) is 1,2,3 range(1,3) is 1,2 So m is increased by 1 for 6 times (3*2) Values of x and y are not used, but they are x, y 1, 1 1, 2 2, 1 2, 2 3, 1 3, 2
30th Oct 2020, 3:04 PM
Benjamin Jürgens
Benjamin Jürgens - avatar