Question

Dag Hansteen dhansteen at hotmail.com
Mon Aug 9 19:42:46 CEST 2004


>>> s = "2+2"
>>> answer = int(str(s))
Traceback (most recent call last):
  File "<pyshell#64>", line 1, in ?
    answer = int(str(s))
ValueError: invalid literal for int(): 2+2

How do I this ? I have a string with a such expression and I want to return the answer in a variable.

Regards Dag Hansteen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040809/6d44e1b6/attachment.html>


More information about the Python-list mailing list