On Tue, Jul 21, 2020 at 10:07:47PM +0100, Barry wrote:
- Because that not what else mean today. Its elif never looped.
py> for x in [1,2]: ... print("inside loop") ... else: ... print("elif never looped") ... inside loop inside loop elif never looped
This is why I have long-argued that the keyword here should be *then* not else. The semantics are that the loop executes, *then* the following "else" block executes, unless we have transferred control elsewhere by jumping out of the loop with return, raise, or break.
Mistaking the semantics for "if never looped" is a very common mistake. Welcome to the club :-)