empty clause of for loops
Palpandi
palpandi111 at gmail.com
Fri Mar 18 15:10:26 EDT 2016
On Wednesday, March 16, 2016 at 3:53:48 PM UTC+5:30, Sven R. Kunze wrote:
> Hi,
>
> a colleague of mine (I write this mail because I am on the list) has the
> following issue:
>
>
> for x in my_iterable:
> # do
> empty:
> # do something else
>
>
> What's the most Pythonic way of doing this?
>
> Best,
> Sven
You can do like this.
if not my_iterable:
<do something>
for x in my_iterable:
<do something>
More information about the Python-list
mailing list