keyList = sorted(d.keys())
for i, v in enumerate(keyList):
    if v == 'eeee':
        print(d[keyList[i + 1]])
print(d[keyList[i - 1]])
In Python, How can I get the next and previous key:value of a particular key in a dictionary?