Here is a code:
class Child(object):
def chunks(l, n):
""" Yield successive n-sized chunks from l.
"""
for i in xrange(0, len(l), n):
yield l[i:i+n]
k= range(1, 10)
print k
print Child().chunks(k,2)
When I execute this code, python throws following error:
[1, 2, 3, 4, 5, 6, 7, 8, 9]
Traceback (most recent call last):
File "/home/Sample.py", line 19, in
print Child().chunks(k,2)
TypeError: chunks() takes exactly 2 arguments (3 given)
Please find my snippet !