I have a written a loop for and if condition and I want to break to loop completely when if gets satisfied.
while count:
i=0
for line in read_record:
#print str.strip(count[1:28])
#print str.strip(read_record[i])
if string.find(str.strip(read_record[i]),str.strip(count[1:28]))>0:
code=str.strip(read_record[i+19])+str.strip(read_record[i+20])
print code[25:]
break
i=i+1
So here if the if string.find condition gets satisfied I want to go to while loop flow. Please tell me what will be the best place to break and how should I modify the program so that once the if condition is satisfied I am out of the loop and start again with while loop.
Your code already does that. Though it is unclear why do you need nested loops and what are those magic numbers for. Here’s your code refactored a bit for readability: