why this is printing like this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4th Apr 2020, 3:40 PM
HAMZA
3 Answers
0
I believe you want to print out the elements of the list till it gets to 55. Then, the mistake is in the for loop. It ought to be; for y in x: print(y) if y == 55: break but this code will include 55. The name of your code is 'break 55' so i think it ought to break when it encounters 55 hence, the checking for 55 should come before the printing. The final for loop would then be... for y in x: if y == 55: break print(y) #hope this helps.
4th Apr 2020, 3:53 PM
Jolomi Tosanwumi
+ 1
thanks
4th Apr 2020, 6:06 PM
HAMZA
+ 1
My pleasure
4th Apr 2020, 6:12 PM
Jolomi Tosanwumi