Adding Values From Tuples of Same Length

后端 未结 6 991
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 05:07

In a graphical program I\'m writing using pygame I use a tuple representing a coordinate like this: (50, 50).

Sometimes, I call a function which returns another tupl

6条回答
  •  佛祖请我去吃肉
    2020-12-06 05:30

    Well, one way would be

    coord = tuple(sum(x) for x in zip(coord, change))
    

    If you are doing a lot of math, you may want to investigate using NumPy, which has much more powerful array support and better performance.

提交回复
热议问题