[ create a new paste ] login | about

Link: http://codepad.org/Br0NHeqH    [ raw code | output | fork ]

Python, pasted on Jun 30:
import math

def seperate(array, divider):
        result = []
        count = math.ceil(float(len(array)) / divider)
        i = 0

        while i < count:
            limit = (i + 1) * divider
            ii = i * divider

            while ii < limit and ii < len(array):
                result += array[ii]
                ii += 1

            i += 1


        return result


array = [1, 2, 3, 4, 5, 6, 7]

seperate(array, 3)


Output:
1
2
3
4
5
6
Traceback (most recent call last):
  Line 24, in <module>
    seperate(array, 3)
  Line 13, in seperate
    result += array[ii]
TypeError: 'int' object is not iterable


Create a new paste based on this one


Comments: