Given a list of tuples, the following code removes the empty lists and prints out the remaining elements:
tuples=[[(16, 178)], [], [(46, 183)], [(15, 55)], [(42, 79)], [(54, 192)], [], [(2, 86)], []]
res = [ele for ele in tuples if ele != []]
print(res)
I now want to replace the empty lists with the tuple [(0,0)]
. However, this line gives me an 'invalid syntax' error:
res = [ele=[(0,0)] for ele in tuples if ele != []]