Skip to content

Instantly share code, notes, and snippets.

@Cyril-Pop
Created April 25, 2021 10:33
Show Gist options
  • Save Cyril-Pop/80a18eb4b2ed3287e161722bf4a8ad19 to your computer and use it in GitHub Desktop.
Save Cyril-Pop/80a18eb4b2ed3287e161722bf4a8ad19 to your computer and use it in GitHub Desktop.
find all index in list of item
lst = ["car","blue","car","red"]
var = {xvalue:[idx for idx, value in enumerate(lst) if value == xvalue] for xvalue in set(lst)}
print var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment