I have a list of numbers and list of strings:
data = [1, 2, 3, 1, 3]
labels = ['a','b','c']
How do I replace the numbers in data with the labels so that I will get data equals:
['a','b','c','a','c']
I tried setting labels to
mappings [('a', 1), ('b',2), ('c',3)]
and using a for loop to replace the data variable but I cannot seem to replace a list.
[labels[i-1] for i in data]should work