dimanche 7 janvier 2018

How to generalizing the creation of a list with many variables and conditions of `if`?

I create a list as follows:

['v0' if x%4==0 else 'v1' if x%4==1 else 'v2' if x%4==2 else 'v3' for x in list_1]

How to generalize the creation of such a list, so that it can be easily expanded by a larger number of variables and subsequent conditions?

Aucun commentaire:

Enregistrer un commentaire