0

There are similar questions but i didn't find a clean answer for what i think is simple.

I want to get once the first 1000 elements of a list, then the first 2000 ecc...

for i in range(1000, len(l1), 1000):
     a = l1[:i]

but obviously won't work if len(l1) % 1000 != 0 or if len(l1) < 1000. What is an easy solution for this?

Thanks.

Fruff
  • 47
  • 6
  • 3
    [How do you split a list into evenly sized chunks?](https://stackoverflow.com/q/312443/2301450) – vaultah Aug 21 '17 at 14:14
  • 1) Why do you think this won't work for lists that have more or less a multiple of 1000 number of elements 2) are you sure the `range` should start at 1000 and not 0? – omu_negru Aug 21 '17 at 14:16

0 Answers0