I am trying to add (0.5,-0.5) to (i,j) elements in the list I4 but there is an error. I present the expected output.
I3 = [[(0, 0), (0, 1)], [(0, 0), (1, 0)], [(0, 1), (1, 1)], [(1, 0), (1, 1)]]
temp = []
for t in range(0,len(I3)):
I4 = [(j, -i) for i, j in I3[t]]
temp.append(I4)
print("I4 =",temp)
#I4 = [[(0, 0), (1, 0)], [(0, 0), (0, -1)], [(1, 0), (1, -1)], [(0, -1), (1, #-1)]]
temp2 = []
for h in range(0,len(I3)):
I5 = [(i+0.5, j-0.5) for i, j in I4[h]]
temp2.append(I5)
print("I5 =",temp2)
The error is
in <listcomp>
I5 = [(i+0.5, j-0.5) for i, j in I4[h]]
TypeError: cannot unpack non-iterable int object
The expected output is
I5 = [[(0.5, -0.5), (1.5, -0.5)], [(0.5, -0.5), (0.5, -1.5)], [(1.5, -0.5), (1.5, -1.5)], [(0.5, -1.5), (1.5, -1.5)]]