if without else one liner python code example
Example 1: python one line if without else
var = [exp] if [condition] else None
Example 2: python one line if without else
>>> myList = []
>>> False and myList.append('myString')
False
>>> myList
[]
>>> True and myList.append('myString')
>>> myList
['myString']