I've got a list with (for example) 100 entries of the sort ['A0', 'B0', 'A1', 'B1', 'A2', 'B2', ... 'A99', 'B99']
.
I'd now like to make this into a list of 50 entries with each entry a tuple (Ai, Bi)
such that they are grouped together. So the result should be
[('A0','B0'),('A1','B1'),('A2','B2'),...,('A99','B99')]
. Is there a shortcut to achieve this or do I have to use a loop like
for i in numpy.arange(0,100,2):
newlist.add((oldlist[i], oldlist[i+1]))
I'm trying to do quick and advanced programming in python so I'd prefer using shortcuts, list comprehension, ... and not simple for loops where possible