I need help with a function that outputs a dictionary that contains the composition between R1 and R2 it's output represents R2 ◦ R1
as of now, I have
def composition(R1,R2):
d = {i:R2[R1[i]] for i in R1}
print(d)
this function works inputting
R1 = {1:'a',2:'b',3:'c'}
R2 = {'a':'A','b':'B','c':'C'}
output: {1: 'A', 2: 'B', 3: 'C'}
what I need to work is
R1 = {1 : [2, 3], 2 : [3], 3 : [4], 4 : [1, 3]}
R2 = {1 : [3], 2 : [1, 4], 3 : [2], 4 : [1, 2]}
output should be: R2 ◦ R1 = {1 : [1, 2, 4], 2 : [2], 3 : [1, 2], 4 : [2, 3]}
what I get is unhashable type list
Any help would be great, Thank You.