python - Adding Values From Tuples of Same Length -


itemprop = "text">

In a graphical program, I am writing pygame, I use Tupal that represents a coordinate like this: (50 , 50).

Occasionally, I call a function that gives another tube such as (3, -5), which represents the change in coordination.

What is the best way to add change value? It would be good for coordinating value if I can do something like coordination + = change, but it appears that just two topleps (50, 50) , 3, -5) will add something like that. The first value was to add 1 value and 2 got the second and a result of the tuple.

So far I am using this very tedious method: coord = (coord [0] + change [0], coordination [1] + change [1])

What is a better and more precise method for connecting the values ​​of two tuples of the same length, it is particularly important how to do it, if Tuples is an arbitrary length or especially long length The previous method makes it even more tiring.

< P> If you are doing a lot of math, you may want to test using, which has more powerful array support and better performance.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -