title: loop list as if last element precedes first
body: <p>If I have n elements in a list, I want start with the first element and slice the next x elements for the entire list such that it treats the last element in the list as if it precedes the first.</p>
  <p>Example:</p>
  <p>if I want slices of 5 elements each and my list is:</p>
  <pre><code>lst = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;]
  </code></pre>
  <p>I want the output to be for each slice:</p>
  <pre><code>['b', 'c', 'd', 'e', 'f']
  
  ['c', 'd', 'e', 'f', 'a']
  
  ['d', 'e', 'f', 'a', 'b']
  
  ['e', 'f', 'a', 'b', 'c']
  
  ['f', 'a', 'b', 'c', 'd']
  
  ['a', 'b', 'c', 'd', 'e']
  </code></pre>
  <p>This is my current code:</p>
  <pre><code>
  lst = [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&quot;, &quot;f&quot;]
  
  i = 1
  j = 6
  
  while i &lt;len(l):
      print(l[i:j], end = &quot; &quot;)
      i += 1
      j += 1
  
  </code></pre>
  <p>My current output is:</p>
  <pre><code>['b','c','d','e','f']
  
  ['c', 'd', 'e', 'f']
  
  ['d', 'e', 'f']
  
  ['e', 'f']
  
  ['f']
  </code></pre>