For loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

For loop

Why the output is 17 for this loop? Please help! count = 20 for x in range(0,10): count = count - 1 if x == 2: break print(count)

30th Dec 2021, 1:56 PM
Knowledge Is Power
Knowledge Is Power - avatar
2 Answers
+ 1
x= 0, 1 and 2 in the loop 20 -1, -1 and -1 = 17 if x == 2 the loop will be left
30th Dec 2021, 2:05 PM
JaScript
JaScript - avatar
+ 1
Thank you for your response!
30th Dec 2021, 2:42 PM
Knowledge Is Power
Knowledge Is Power - avatar