I have a list of strings:
l = ["pear", "apple", "pear", "banana"]
and would like to code each element as an integer, starting from 0 to the number of unique elements in the list, so the result would be
[0,1,0,2]
I can only think of complicated solutions, is there an easy one-liner for this?