split long list into chunks of 100
def chunks(l, n): n = max(1, n) return (l[i:i+n] for i in range(0, len(l), n))
Here is what the above code is Doing:
1. We’re using the built-in function enumerate to get the index of each element in the list as we go through it.
2. We’re using the built-in function range to generate a list of numbers.
3. We’re using the built-in function len to get the length of the list.
4. We’re using a generator expression to create a generator.
5. We’re using the built-in function max to ensure that n is at least 1.