Title: SymPy.solvers.solve() returns empty list
Tags: python;sympy
Question: While using sympy.solve() to try and solve simple linear equations, the function just returns an empty list.
Here is my code:
from sympy import Symbol
from sympy.solvers import solve
from sympy.parsing.sympy_parser import parse_expr as parse
x = Symbol('x')
equation = input('Enter an equation: ')
equation = message.content.split()[1].replace('=',',')
solution = solve(parse(equation))
For equation = 'x+3=8',  print(solution) just prints []
Can anyone figure out why this is happening?
Thanks!
Comment: Why are you replacing `=` with `,`? This works: `solve(parse_expr('Eq(x+3,8)'))`

Comment: @Oscar Benjamin This codepiece is actually for a discord bot. The input will have an equal sign denoting the equation, not a comma. Try ```solve(parse_expr('Eq(x+3=8)'))``` and it raises an error

Here is the accepted answer: I'm not sure what the best practice here is, but using Eq here will work.
The code after a few changes-
from sympy import Symbol, Eq
from sympy.solvers import solve
from sympy.parsing.sympy_parser import parse_expr as parse
x = Symbol('x')
equation_1 = input('Enter an equation: ')
equation_2 = equation_1.split('=')
solution = solve(Eq(*[parse(i) for i in equation_2]), x)
print(solution)
example output-
Enter an equation: x+1=x**2
[1/2 - sqrt(5)/2, 1/2 + sqrt(5)/2]

Here is another answer: The standard way to handle this parsing is to use the &quot;battery&quot; transformations:
&gt;&gt;&gt; from sympy.parsing.sympy_parser import parse_expr, T
&gt;&gt;&gt; parse_expr('x=1',transformations=T[1,9]) # auto-symbol and convert =
Eq(x, 1)
&gt;&gt;&gt; solve(_)

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:08/08/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><sympy>', 'Title': 'SymPy.solvers.solve() returns empty list', 'ViewCount': 30, 'id': 73284507, 'user_AboutMe': None, 'user_AccountId': 25537740.0, 'user_DisplayName': '433MEA', 'user_Reputation': 44.0, 'user_Views': 7.0, 'user_id': 19324492.0}}