title: How do you set up a for loop which basically goes around in a cyclic pattern for a set amount of numbers? For example, how to go from 123 to 231to 312
body: <p>could someone please show me how to approach this type of question as I am revising for my end of semester exams.</p>
  <blockquote>
  <p>Write a function cyclical(n) that produces an n ×n pattern in which the
  numbers 0 to n −1 appear in every row, but where the numbers in each row
  are cyclically shifted with respect to those in the row above. (7 marks)</p>
  <pre><code>0 1 2 3 4 5 6 7
  1 2 3 4 5 6 7 0
  2 3 4 5 6 7 0 1
  3 4 5 6 7 0 1 2
  4 5 6 7 0 1 2 3
  5 6 7 0 1 2 3 4
  6 7 0 1 2 3 4 5
  7 0 1 2 3 4 5 6
  </code></pre>
  </blockquote>
  <p>This is what I have so far:</p>
  <pre class="lang-py prettyprint-override"><code>answer=0
  for i in range(0,8):
      for i in range(0,8):
          answer=i+1
          print(answer,end=&quot;&quot;)
      print()
  </code></pre>