Saturday, 8 January 2022

Cleaner way of dividing a list of tuples into multiple lists

The title is self explanatory, is there a one line expression to do so ?

Reproducible example:

Data = [(21,1,2000), (30,0,1991), (27,0,1994)]

age = [el[0] for el in Data]
sex = [el[1] for el in Data]
birth = [el[2] for el in Data]

print(age, sex, birth)


from Cleaner way of dividing a list of tuples into multiple lists

No comments:

Post a Comment