For loops through and at the first instance of a conditional match, it breaks and exits the loop.
Here is an example for a list in Python.
PythonFor_Break_0
The first two items in the list does not satisfy the condition and therefore you have two responses and when the program encounters 2 which is divisible by 2 (it's using modulo) the condition is satisified and it prints and then exits.
Here is the same in Visual Studio's Python interactive.
PythonFor_Break_1
Here is an example for a list in Python.
PythonFor_Break_0
The first two items in the list does not satisfy the condition and therefore you have two responses and when the program encounters 2 which is divisible by 2 (it's using modulo) the condition is satisified and it prints and then exits.
Here is the same in Visual Studio's Python interactive.
PythonFor_Break_1
No comments:
Post a Comment