title: How to increment x number of elements repeatedly y times in Python
body: <p>I have <code>x</code> which is number of elements needed and <code>y</code> which is number of times the elements are needed.</p>
  
  <p>For example:</p>
  
  <pre><code>&gt;&gt;&gt; x = 5
  &gt;&gt;&gt; y = 2
  &gt;&gt;&gt; for i in range(y):
  ...  for j in range(x):
  ...   print j,
  ... 
  0 1 2 3 4 0 1 2 3 4
  </code></pre>
  
  <p>Expected output is:</p>
  
  <pre><code>0 1 2 3 4
  5 6 7 8 9
  </code></pre>
  
  <p>Can someone help me in achieving the expected output?
  <code>for</code> loop or list comprehension any way is fine.
  Thanks in advance.</p>