Python - Non K distant elements
Given a list, the task is to write a Python program to extract all the elements such that no element is at K distant from one other. Examples: Input : test_list = [8, 10, 16, 20, 3, 1, 7], K = 2 Output : [16, 20, 7] Explanation : 16 + 2 = 18, 16 - 2 = 14, both are not in list, hence filtered. Input