+ 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
4 odpowiedzi
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..
+ 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
+ 1
Thank you. Got the answer
0
x == "jack" : continue
x == "jake" : break
In between, add print out side if block