请问如何将偏移添加到嵌套的元组列表中并输出为指示,即
ball = [[(2,0),(3,9)],[(7,4),(3,4)]]
offsets = [(50,50)]
如何添加偏移量,以获得如下输出:
ball1 = [[(52,50),(53,59)],[(57,54),(53,54)]]
谢谢
答案 0 :(得分:3)
您可以按照以下方式执行此操作:
ball1 = ball[:]
for i,lst in enumerate(ball):
for j,item in enumerate(lst):
ball1[i][j] = (ball[i][j][0]+offsets[0][0], ball[i][j][1]+offsets[0][1])