I have a list whose elements are either a json object or None. What would be the most elegant way to convert it into a list of 0's and 1's. For example here is my input :
mylist = [j1, j2, None, j3, None]
j1, j2, j3 are json objects. The expected output is
output_list = [1, 1, 0, 1, 0]
I can implement this using a for loop followed by if statement. Is there a way to do it which is more elegant/pythonic?