Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You have probably mistyped your attempt, which gives another error....

You have probably mistyped your attempt, which gives another error....

After a few guesses, I supposed that you meant :

def vbl(c,ex):
    l=len(c)
    V=1 
    for i in range(l):
        V=V*(c[i]**ex[i])
    return V

which gives :

sage: vbl([x, y, z],[2, 3, 4])
x^2*y^3*z^4

but :

sage: vbl(["x, y, z"],[2, 3, 4])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[ Snip... ]
TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

[x, y, z] is a list of three symbolic variables, but `["x, y, z"] is a list of one string...

Note :

sage: prod(map(lambda a,b:a**b,[x, y, z],[2, 3, 4]))
x^2*y^3*z^4