I have a list with 4 different numbers, 10 numbers in total. To each of those numbers, I want to assign a color/word. The question is thus, how do I go from a list of numbers to a list of colors where every same number is represented by the same color/word?
Initial list:
my_list = [72, 50, 3, 50, 16, 72, 3, 72, 3, 50]
Expected output:
print(my_list) -> ['red', 'blue', 'green', 'blue', 'black', 'red', 'green', 'red', 'green', 'blue']
What did I try?
I extracted unique numbers from my_list:
my_list = [72,50,3,50,72,3,72,3,50]
UniqueList = list(set(my_list))
print(UniqueList)
Now I need to assign a color from a list of colors ['red', 'blue', 'green', 'black', 'yellow', 'purple'] to each of those 4 unique numbers and then generate my_list again with colors. Unfortunately I have no clue how to go forward. Any ideas?