title: take no of neighbours from the given index of list. what is the best practice or effiecient performance for given solution?
body: <p>I want to take (c=3) number of elements from the given index (idx) of (a_list) list.<br>
  <strong>Input</strong>:</p>
  
  <pre><code>a_list = [1,2,3,4,5,6,7,8,9,10]  
  idx = 4  
  c = 3        # no of neighbours to take  
  </code></pre>
  
  <p><strong>Output</strong>:
  <code>[2,3,4,6,7,8]</code></p>
  
  <p><strong>Solution 1:</strong> Append forward and backward elemnts through separate loops.</p>
  
  <pre><code>def get_result(a_list, idx, c):
  
    for i in range(1,c+1):
      result.append(a_list[idx - i])
  
    for i in range(1,c+1):
      result.append(a_list[idx + i])
  
    return result
  </code></pre>
  
  <p><strong>Solution 2:</strong> Make two separate list for forward and backward elements with one for loop and merge.</p>
  
  <pre><code>def get_result(a_list, idx, c):
    forward_list, backward_list = [],[]
  
    for i in range(1,c+1):
      forward_list.append(a_list[idx - i])
      backward_list.append(a_list[idx + i])
  
    result = [forward_list, backward_list]
    return result
  </code></pre>