Pythonic way to return list of every nth item in a larger list
>>> lst = list(range(165)) >>> lst[0::10] [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160] Note that this is around 100 times faster than looping and checking a modulus for each element: $ python -m timeit -s “lst = list(range(1000))” “lst1 = [x for x in lst … Read more