I have dictionary like:
{0:'I', 3: 'Mr.', 5: 'Nevrekar', 8: 'JK', 14: 'Soham', 15: 'Sharma', 4: 'Akshay'}
I want to return it the 1st combination of consecutive keys(minimum 2). In above case it's (3,4,5).
so it would return a list:
['Mr.', 'Akshay', 'Nevrekar'].
How can I achieve this?
My Attempt:
name=[]
count = 0
for k,g in name_list.items():
if count == 0:
temp =None
if k-1 == temp:
name.append(g)
count+= 1
temp = k
which is giving output as:
['Akshay', 'Nevrekar', 'Sharma']