This is the first question I am asking on this forum, so I welcome your feedback on making this more helpful to others.
Say I have this list:
IDs = ['First', 'Second', 'Third']
and this dictionary:
statistics = {('First', 'Name'):"FirstName", ('Second','Name'):"SecondName", ('Third','Name'):"ThirdName"}
Is there a shorter, easier to read one-liner than the following?
firstID = IDs[[statistics[ID,'Name'] for ID in IDs].index('FirstName')]
Many thanks
Aucun commentaire:
Enregistrer un commentaire