title: Is this how you paginate, or is there a better algorithm?
body: <p>I want to be able to take a sequence like:</p>
  
  <pre><code>my_sequence = ['foo', 'bar', 'baz', 'spam', 'eggs', 'cheese', 'yogurt']
  </code></pre>
  
  <p>Use a function like:</p>
  
  <pre><code>my_paginated_sequence = get_rows(my_sequence, 3)
  </code></pre>
  
  <p>To get:</p>
  
  <pre><code>[['foo', 'bar', 'baz'], ['spam', 'eggs', 'cheese'], ['yogurt']]
  </code></pre>
  
  <p>This is what I came up with by just thinking through it:</p>
  
  <pre><code>def get_rows(sequence, num):
      count = 1
      rows = list()
      cols = list()
      for item in sequence:
          if count == num:
              cols.append(item)
              rows.append(cols)
              cols = list()
              count = 1
          else:
              cols.append(item)
              count += 1
      if count &gt; 0:
          rows.append(cols)
      return rows
  </code></pre>