I am trying to find the middle element of a list and then take the next 3 items forwards and backwards and make a new list in python.
For example:
lst = [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q]
x = my_func(lst)
print(x)
[f, g, h, i, j, k, l]
How would one accomplish this?
I know I can find the middle by doing this:
middle_index = (len(lst) - 1)//2
but I am a bit stuck on how to slice it afterwards.