Wolfram Alpha Dictionary Element Problem
EthanChenster opened this issue · comments
Im trying to make a wolfram alpha assistant and I got this error
Code:
import wolframalpha
import ssl
app_id = 'REDACTED'
wolframbot = wolframalpha.Client(app_id)
res = wolframbot.query('Temperature in Las Vegas Nevada')
for pod in res.pods:
print(pod.subpods)
for sub in pod.subpods:
print(sub.plainText)
Error:
<map object at 0x7ff848b35be0>
Traceback (most recent call):
file "main.py", line 9 in <module>
for sub in pod.subpods:
ValueError: dictionary update sequence element #0 has length 1; 2 is required
Is there any solution?
I think WolframAlpha may have changed their API format again since the given format is now a dictionary.
Therefore, you can use the following code to access the plaintext element:
for pod in res.pods: print(pod["subpod"]["plaintext"])
Maybe @jaraco should check if this applies in all cases?
I think WolframAlpha may have changed their API format again since the given format is now a dictionary.
Therefore, you can use the following code to access the plaintext element:
for pod in res.pods: print(pod["subpod"]["plaintext"])
Maybe @jaraco should check if this applies in all cases?
Wait what should my code look like?
@ScottyEthan, here's the code with the updated section:
import wolframalpha
import ssl
app_id = 'REDACTED'
wolframbot = wolframalpha.Client(app_id)
res = wolframbot.query('Temperature in Las Vegas Nevada')
for pod in res.pods:
print(pod["subpod"]["plaintext"])
Happy coding :D
Thanks!