I would like to find value(s) in the dictionary that the first N characters are same as another string.
For example:
I would like to get all values that first 4 characters are "abcd" and return its key
string = "abcd"
dict = {'k1' : 'abcd4545', 'k2' : 'abab1234', 'k3' : 'abcd789456'}
Result: k1 and k3 should be returned
I think it can be done by looping all the values in the dictionary and getting the first N characters for comparing.
But I need to handle a dictionary with large amount of data, is there any better way to do this?