I have a list of non-unique strings:
list = ["a", "b", "c", "a", "a", "d", "b"]
I would like to replace each element with an integer key which uniquely identifies each string:
list = [0, 1, 2, 0, 0, 3, 1]
The number does not matter, as long as it is a unique identifier.
So far all I can think to do is copy the list to a set, and use the index of the set to reference the list. I'm sure there's a better way though.