How to keep sublists from index start to end exclusive in a list of lists with Python

1 Answer

0 votes
def keep_sublists(lst_lst, lower, upper):
    return lst_lst[lower:upper]

list_of_list = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
start = 1
end = 3

result = keep_sublists(list_of_list, start, end)
print(result)



'''
run:

[[3, 4], [5, 6]]

'''

 



answered Feb 17 by avibootz

Related questions

3 answers 247 views
...