0

I have a mathematical expression, for example : "x45 + x3/2 + ln(x1 - x45)" and I want to create a function, called

find_variables(expression)

which should return the list of the variables contained in the expression, with only one occurrence if the variable appears twice or more in the expression. Here, L = ["x45", "x3", "x1"]

I thought I might use regexes of this kind :

pattern = re.compile(x\d+)

but I don't know how to match then stock the results. Can anyone help me ?

Thank you in advance

0 Answers0