I want to be able to add an attribute to a dictionary but only if the condition I pass in is true. For example:
def addSum(num):
obj = {
'name': "Home",
'url': "/",
num > 0 ? 'data': num
}
Is this possible? I can't find a way to do this in python, I have only seen examples in javascript.