pos = 0
d = {'aaaa': 'a', 'bbbb': 'b', 'cccc': 'c', 'dddd': 'd', 'eeee': 'e',
    'ffff': 'f'}
for i in d:
    pos += 1
if i == 'eeee':
    listForm = list(d.values())
print(listForm[pos - 1])
print(listForm[pos + 1])
In Python, How can I get the next and previous key:value of a particular key in a dictionary?