serhii.net

In the middle of the desert you can say anything you want

25 Jul 2022

Python for..else syntax

TIL another bit I won’t ever use: 21. for/else — Python Tips 0.1 documentation

This exists:

for a in whatveer:
	a.whatever()
else:
	print("Whatever is empty!")

Found it after having a wrong indentation of an else that put it inside the for loop.

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus