Why is this outputting 1, then just stopping? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is this outputting 1, then just stopping?

I was expecting more lines to be outputted. Thanks for any help https://code.sololearn.com/cgsv661Yab43/?ref=app

26th Nov 2019, 12:40 AM
Jacob
1 Answer
+ 2
See your if condition of the outer loop which has a print statement is only true for the first iteration. Because only in that case your "sum" and "i" are equal, so it prints the value 1. But for the rest of the cases your "sum" and "i" are unequal, hence nothing is printed.
26th Nov 2019, 2:07 AM
Avinesh
Avinesh - avatar