0

Explain of a challenge

can anyone explain the code? https://code.sololearn.com/Wgh4JHgO6IlG/?ref=app

17th May 2020, 10:18 AM
Shadman Sakib
Shadman Sakib - avatar
6 Answers
+ 1
The loop will run 9 times. why? because the second loop is j less or equals 3, so the first loop runs 3 times (0, 1, 2) and the second loop runs 3 times as well (0, 1, 2), so you end with 3*3 = 9
17th May 2020, 10:42 AM
coddy
coddy - avatar
0
Shadman Sakib , you have two loops, one nested in another. The nested loop runs three times (0, 1 and 2 => 3 steps). After the completion the outer loop is running 1 time. So you have for each step in outer loop the inner one runs 3 times => 3 * 3 = 9.
17th May 2020, 10:36 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
0
yeah. but why 9?
17th May 2020, 10:36 AM
Shadman Sakib
Shadman Sakib - avatar
0
thank I understand
17th May 2020, 10:47 AM
Shadman Sakib
Shadman Sakib - avatar