Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The variable i was overwritten with $2$.

The error can be recovered as follows:

sage: var( 'h,i' );
sage: solve( [h+i == 7, h-i == 3], [h,i] )
[[h == 5, i == 2]]
sage: for i in range(3):    print "i = %s" % i
i = 0
i = 1
i = 2
sage: solve( [h+i == 7, h-i == 3], [h,i] )
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-628-48574179ae51> in <module>()
----> 1 solve( [h+i == Integer(7), h-i == Integer(3)], [h,i] )

/usr/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
    974         for i in x:
    975             if not isinstance(i, Expression):
--> 976                 raise TypeError("%s is not a valid variable." % repr(i))
    977     elif x is None:
    978         vars = f.variables()

TypeError: 2 is not a valid variable.