Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Keyword can't be an expression error with subs()

I want to be able to iterate through a list of variables for function and make assignments to each of them. Here's an example that shows the issue I'm having:

R.<x,y> = PolynomialRing(QQ,2)
f = x^2+y^2
variables = [x,y]
f.subs(variables[0]=1)

This gives "SyntaxError: keyword can't be an expression." How can I get around this? The goal is to use a loop to make substitutions for some variables, look at what happens, then in the next iteration different substitutions will be made.