Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To save to a file, you may try the following.

with open('filename.txt','w') as outfile:
    outfile.write("{0}\n".format(what_you_want(8)))

Searching for "write to file in python" might give some insight into this aspect of Python.

If you wish to process a list by chunks, then looking up "slicing in Python" might be useful. Given a list L, you may access the second chunk of length 40 by using L[40:80]. So using slicing within a for loop could produce the desired result.