How to display more than one result with Wolfram Alpha API (python)

136 Views Asked by At

So I'm building a bot and its query through the wolfram alpha api is pretty simple

    res = wclient.query(query)
    output = next(res.results).text
    print(output)

It works fine for linear equations which have one answer, like x + 5 = 10, it returns x = 5 But for quadratics which require two solutions, it sends only one root, For example x² - 5x + 6 = 0, returns only x = 2, when x = 3 is also a solution

enter image description here

Is there a way to display all the results?

1

There are 1 best solutions below

1
Mahesh Ramani On
            res = wclient.query(' '.join(query))
            for result in res.results:
                if result.title == "Roots":
                    output=result.texts
                    print("The answer is "+str(output))

wont work for answers that don't have roots