1a_list = [1,2,3,4,5]
2
3for index, elem in enumerate(a_list):
4 if (index+1 < len(a_list) and index - 1 >= 0):
5Check index bounds
6
7 prev_el = str(a_list[index-1])
8 curr_el = str(elem)
9 next_el = str(a_list[index+1])
10
11 print(prev_el, curr_el, next_el)