This post series is the Solutions of the Programming — Principles and Practice Using C++ (Second Edition) written by Bjarne Stroustrup Chapter 6: Writing a Program Drill
Tag: Programming
For/Else Loop
For/Else Loop Python Today I encounter python snippet code and something take my attention. And the concept is similar to below code.
1 2 3 4 5 6 7 |
for i in range(7): print("for") if i == 10: print("if") break else: print("else") |
1 2 3 4 5 6 7 8 9 |
Output: for for for for for for for else |
And I recognize else statement is not given an error. After some research, I found the miracle, for/else loop. The concept of…