1.24. Inner Elements ¶
In this question you are required to write a program that prints the innermost m elements in list format for a given list of length n. It is guaranteed that m ≤ n, and both numbers m and n are of the same parity.
Sample I/O:
Input:
[1,2,3,4,5,6]
2
Output:
[3,4]
Input:
[10,4,6,2,7,32,6,76,99]
3
Output:
[2,7,32]
lst = eval(input())
m = int(input())
n = len(lst) # length of list
print(lst[(n-m) // 2 : (n+m) // 2]) # notice the slicing operator