title: SageMath How to fix List for Taxicab numbers to be properly generated?
body: <p>I am trying to write a function in SageMath that prints all Taxicab numbers (numbers who equal the sum of multiple sets of two values cubed and then added together) less than or equal to a certain value(in my code I refer this number as the variable t).</p>
  
  <p>I can't seem to figure out how to make the appropriate changes for the lists(which I originally wrote in Python 2.7) to run in SageMath. As a result I keep getting the error: </p>
  
  <pre><code>Traceback (most recent call last):            for i in range(1,len(sums)-1):
    File "", line 1, in &lt;module&gt;
  
  File "/private/var/folders/96/g5hyl4ps29dglpy8fnwww6x80000gn/T/tmpWiTKG1/___code___.py", line 16, in &lt;module&gt;
  exec compile(u'Ramanujan(_sage_const_10000 )
  File "", line 1, in &lt;module&gt;
  
  File "/private/var/folders/96/g5hyl4ps29dglpy8fnwww6x80000gn/T/tmpWiTKG1/___code___.py", line 7, in     Ramanujan
  crev[x3] = x + _sage_const_1 ;
  IndexError: list assignment index out of range
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>def Ramanujan(t):
      cubes = [x**3 for x in range(1,t/10)];
      crev = [] # Calculating Cube Roots;
      for x,x3 in enumerate(cubes):
          crev[x3] = x + 1;
          sums = sorted(x + y for x in cubes for y in cubes if y &lt; x) # Organizing Data
          for i in range(1,len(sums)-1):
              if sums[i-1] != sums[i] and sums[i] == sums[i+1]: # Finding solutions
                  if sums[i]&lt;=t: # Limiting how many solutions printed.
                      print "%10d"%(sums[i]) # Printing desired outputs
                  else:
                      break # Ending the function.
  
  Ramanujan(10000)
  </code></pre>
  
  <p>(Ramanujan(10000) should cause the function to print 2 values less than 10,000)</p>
  
  <p>Do I need to declare the variables in my function as variable objects?
  Do I not need to create the blank list crev before populating it?
  Is it just a problem with how I am trying to use lists?</p>