'break' is used to break out of the nested loop.
main_keyword = ["11111", "22222", "333333", "44444", "55555"]
for pro in main_keyword:
# 1
for i in range(3):
if pro == '333333':
print(pro, "failure")
break
else:
print(pro, "Pass")
pass
# 2
for a in range(3):
print(a)
However, the #1 for loop escapes, but the #2 for loop is executed.
11111 Pass
11111 Pass
11111 Pass
0
1
2
22222 Pass
22222 Pass
22222 Pass
0
1
2
333333 failure
0
1
2
44444 Pass
44444 Pass
44444 Pass
0
1
2
55555 Pass
55555 Pass
55555 Pass
0
1
2
What I want is if pro == '333333' , then proceed to the next operation of the top-level loop without working on both for loop #1 and #2.
11111 Pass
11111 Pass
11111 Pass
0
1
2
22222 Pass
22222 Pass
22222 Pass
0
1
2
333333 failure
44444 Pass
44444 Pass
44444 Pass
0
1
2
55555 Pass
55555 Pass
55555 Pass
0
1
2
I want the above result. help