+ 1

Why doesn't this work ? How can i ignore jack and stop when jake comes ?

friends =["ron","chris","jack",'jake',"brain"] for x in friends: if("jack" in friends): print(x) continue if("jake" in friends): print(x) break https://code.sololearn.com/cNnvqtVaL19f/?ref=app

26th Aug 2022, 8:39 AM
Pro Coder
Pro Coder - avatar
4 Answers
0
friends =["ron","chris","jack",'jake',"brain"] for x in friends: if x == "jack" : continue if x == "jake" : break print(x) #do you want to print "jake"? then print add in between..
26th Aug 2022, 10:16 AM
Jayakrishna 🇼🇳
+ 1
But it doesn't ignores jack and prints the first two names is this the way or what is the mistake I am making. https://code.sololearn.com/cNnvqtVaL19f/?ref=app
26th Aug 2022, 10:10 AM
Pro Coder
Pro Coder - avatar
+ 1
Thank you. Got the answer
26th Aug 2022, 10:24 AM
Pro Coder
Pro Coder - avatar
0
x == "jack" : continue x == "jake" : break In between, add print out side if block
26th Aug 2022, 10:01 AM
Jayakrishna 🇼🇳