954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

nested for loop break

for i in file:
   if i == 0:
       break
   else:
       y = i[0]
       for k in gile:
           ~~~~
           break


if i write something like this, which line does the program read after the second break?

thanks

apeiron27
Newbie Poster
9 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

the second break stops the current loop it's in so it should return to the first loop

"Why not try it yourself to see what happens, you can use print statements to see where the program is heading"

zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: