Python Tip of the Day - Double If's in Comprehensions
Posted on Wed 11 April 2018 in Posts • Tagged with pythonTipOfTheDay, python
So I was reviewing a coworkers pull request today and saw something I hadn't seen in
Python before. As it turns out you can have multiple if
clauses on a list comprehension.
For example:
>>> [v for v in range(50) if v % 2 == 0 if v > 10] # all even numbers …
Continue reading