how to use list compression with conditional formatting

Solutions on MaxInterview for how to use list compression with conditional formatting by the best coders in the world

showing results for - "how to use list compression with conditional formatting"
Théo
04 May 2017
1# You can totally do that. It's just an ordering issue:
2
3[unicode(x.strip()) if x is not None else '' for x in row]
4# In general,
5
6[f(x) if condition else g(x) for x in sequence]
7# And, for list comprehensions with if conditions only,
8
9[f(x) for x in sequence if condition]
10
similar questions