title: Conway sequence in python
body: <p>I have an assignement for which I have to write an algorithm who generates the l lines of the Conway sequence of a chosen r integer.
  Example for l=8 and r=1 :</p>
  
  <pre><code>1
  1 1
  2 1
  1 2 1 1
  1 1 1 2 2 1
  3 1 2 2 1 1
  1 3 1 1 2 2 2 1
  1 1 1 3 2 1 3 2 1 1
  </code></pre>
  
  <p>I have tried to write an algorithm in Python3, but I can't manage to get the correct output. I'd appreciate if you could help me to figure out what's wrong... Anyway, here's what I've wrote so far :</p>
  
  <pre><code>r = int(input())
  l = int(input())
  
  cur=str(r).strip()
  print(r)
  for j in range(l-1):
      r=cur
      cur=""
      i=0
      while i&lt;len(r) :
          c=1 #counts the consecutive same "numbers"
          while ((i+c*2)&lt;len(r)) and (r[i]==r[i+c*2]):
              c+=1  
          cur+=str(c)+" "+r[i]+" "  
          i+=c+1
      cur=cur.strip()
      print(cur)
  </code></pre>
  
  <p>And that's the output I'm getting for l=8 and r=1 :</p>
  
  <pre><code>1
  1 1
  2 1
  1 2 1 1
  1 1 1 2 2 1
  3 1 1 1 2 2 1
  1 3 3 1 1 1 2 2 1
  1 1 2 3 6   2 2 1
  </code></pre>
  
  <p>I also feel that my code is pretty ugly so feel free to give your remarks</p>