python if else one line without else 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']