I need some help with coding a specific logic mentioned below in python 3.6.
Say I have a list \'a\'. Note this list is not of static length and the values can vary.