Ask Your Question

Revision history [back]

Python (therefore Sage) offers a try/except system to handle exceptions, see this page for more details.

In your case, you can try something like:

try:
    n = exp.n()
except TypeError:
    print "sorry, no"

Python (therefore Sage) offers a try/except system to handle exceptions, see this page for more details.

In your case, you can try write something like:

try:
    n = exp.n()
except TypeError:
    print "sorry, no"