Subset a list with two non-consecutive slices in Python
Advertisements I’m working with a list in Python and I need to extract elements with indices from 0 to 3 and from 5 to 7 ([0:3] and [5:7]). It could be done by using slicing and concatenation: target_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] subset_indx = list(range(3)) + list(range(4, 7)) subset_list… Read More Subset a list with two non-consecutive slices in Python