You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to use the SymPy parsing for factorial notation but it keeps throwing the invalid syntax error when I use the "!" (standard factorial symbol), however, using the factorial() method works, but I would like to be able to use the symbol
I attach my code in case you want to check, I think I imported everything correctly though
from sympy import parse_expr
from sympy.parsing.sympy_parser import standard_transformations,implicit_multiplication_application,convert_xor,factorial_notation
opt = input("Ingresa la operacion")
transformations = (standard_transformations + (implicit_multiplication_application,convert_xor,factorial_notation))
res = parse_expr(opt, transformations=transformations)
print(res)
The stack trace:
ValueError: Error from parse_expr with transformed code: 'Integer (5 )!'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\tenesiss\Downloads\calc.py", line 8, in <module>
res = parse_expr(opt, transformations=transformations)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tenesiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\sympy\parsing\sympy_parser.py", line 1087, in parse_expr
raise e from ValueError(f"Error from parse_expr with transformed code: {code!r}")
File "C:\Users\tenesiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\sympy\parsing\sympy_parser.py", line 1078, in parse_expr
rv = eval_expr(code, local_dict, global_dict)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tenesiss\AppData\Local\Programs\Python\Python312\Lib\site-packages\sympy\parsing\sympy_parser.py", line 906, in eval_expr
expr = eval(
^^^^^
File "<string>", line 1
Integer (5 )!
^
SyntaxError: invalid syntax
I'm using SymPy v1.12
The text was updated successfully, but these errors were encountered:
I have been trying to use the SymPy parsing for factorial notation but it keeps throwing the invalid syntax error when I use the "!" (standard factorial symbol), however, using the factorial() method works, but I would like to be able to use the symbol
I attach my code in case you want to check, I think I imported everything correctly though
The stack trace:
I'm using SymPy v1.12
The text was updated successfully, but these errors were encountered: