Fangwen Lu wrote: > Dear all- > > If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get > ((1,2),(3,4),(5,6)). What should I do?
This seems to work although I'd like comments from the more experienced Pythonistas out there. >>> foo [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> [(foo[i],foo[i+1]) for i in range(0,len(foo)-2,2)] [(1, 2), (3, 4), (5, 6), (7, 8)] >>> Peace. -- ~noufal _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
