Search This Blog

Friday, October 15, 2010

Spliting a long tuple into smaller tuples

Programmer Question

I have a long tuple like



(2, 2, 10, 10, 344, 344, 45, 43, 2, 2, 10, 10, 12, 8, 2, 10)


and i am trying to split it into a tuple of tuples like



((2, 2, 10, 10), (344, 344, 45, 43), (2, 2, 10, 10), (12, 8, 2, 10))


I am new to python and am not very good with tuples o(2, 2, 10, 10, 344, 344, 45, 43, 2, 2, 10, 10, 12, 8, 2, 10)r lists. My friend said i should split it but i just cant get it -_-



I need to split the tuple into tuples with 4 elements that i will later use a rectangles to draw to a image with PIL.



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails