i am new to Python and running into a bit of an issue. I am fetching a response from an endpoint and returning names and number of documents. Code for that Looks like this:-
def getDetails():
req = requests.get("url").json()
for name in req['collections']:
collection_size = requests.get("string url" + name + "/select?q=*:*&rows=0").json()["response"]["numFound"]
print(name, collection_size)
getDetails()
And my Output looks like this:-
testing1 105042
testing2 558272707
testing3 1328
testing4 1404321
testing5 2152273
testing6 253621
So something like this:-
for key, value in getDetails():
l = tr()
l += td(key, width="10%")
l += td(value, width="80%")
But what if i want to convert it into some sort of dict()
so i can loop over this output and get the name and number?
This is a relatively new concept to me so excuse any naive mistakes. Appreciate the help.
print()
those values directly. Use the values to set items in a dict and you'll have a dict. – Pranav Hosangadi Oct 14 '20 at 16:56