0
I have a dict
x = {'a':[1,2,3], 'b':[4,5,6]}
and I have to extract a key based on an input, in this case assume it is 3
So my output should be a
Here's my code:
x = {'a':[1,2,3], 'b':[4,5,6]}
n = 3
output = [k for k,v in x.items() if n in v]
print(output[0])
Can it be done more efficie...