I am trying to implement a ternary conditional operator in a list-comprehension. I have written it like this:
lst.append(dict2obj(item)) if type(item) is not in ['int'] else lst.append(item) for item in v
Where lst is empty list and v is another list with various elements. Editor is showing it syntactically incorrect. What am I doing wrong?
is(no such keyword in Python to the best of my knowledge)x is y. It isis inthat does not exist.lstis empty, @InbarRose' answer is clearly the best.