How to remove a block from a Json response?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
myrequest = json.loads(x) r =, json=myrequest) result = r.json() #

Get the answer like this:
[{u aa': 11, u price': {u 'max':11, u 'min': 4}}]
From the response I should throw away the key price, but the problem is that it is the following code complains that it can't work with unicodename dictionaries, so you need or a dictionary to make not-unikalnym, or understand how unnecessary the unit is otherwise cut.
for e in result[0]: print(e) if 'price' in e: del e['price']
by | 13 views

1 Answer

0 like 0 dislike
and why loop through the dictionary? (result[0] you have a dictionary and not a list)
you can just
if 'price' in result[0].keys(): del result[0]['price]

Related questions

0 like 0 dislike
4 answers
0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
asked Apr 11, 2019 by VirusBrain
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
40,796 users