Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Python
import wolframalpha
question = input("Question: ")
app_id = "7R3P9U-UWW4V3W35L"
client = wolframalpha.Client(app_id)

res = client.query(question)
anser = next(res.results).text

print(anser)


What I have tried:

i dont know why this code doesnt work
Posted
Updated 6-Aug-23 11:57am
v2
Comments
Richard Deeming 26-Jul-23 6:54am    
Neither does anyone else, since you haven't told us what the error is. "Doesn't work" is not a useful description of your problem.
CPallini 26-Jul-23 7:00am    
Could you please give us the details of such an 'assertion error'?
Richard MacCutchan 26-Jul-23 7:17am    
Have you installed the wolframalpha client? I just ran your code and it works fine .So please provide full details of the question you entered, and most importantly the actual error message that you receive.
OriginalGriff 26-Jul-23 7:17am    
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Use the "Improve question" widget to edit your question and provide better information.
Member 15627495 27-Jul-23 2:25am    
you have to define a 'name' for your 'import' ,
alias is needed.

1 solution

I ran your code as is without issue, see below.
As others have mentioned it doesn't work is of zero use for folks to help, so supply the question you asked and a trace of everything that happened, folks might then be able to advise.

Python
cat w1.py 
import wolframalpha
question = input("Question: ")
app_id = "7R3P9U-UWW4V3W35L"
client = wolframalpha.Client(app_id)

res = client.query(question)
anser = next(res.results).text
print(anser)


Terminal
python3 w1.py 
Question: pi to 15 decimals
3.141592653589793

python3 w1.py 
Question: highest mountain in africa
Mount Kilimanjaro
(19341 feet)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900