I'm trying to get data in JSON file, but before I print out, I want to sort the money.…
- User
I'm trying to get data in JSON file, but before I print out, I want to sort the money. This is my code
with open("cash.json", "r", encoding="utf-8") as f: data = json.load(f) for c in data['NotAdmin']: a_new_list = sorted(c["money"]) print(a_new_list) This is what is inside my cash.json file
{ "NotAdmin": [ { "money": 200.0, "name": "Sam", "password": "1234" }, { "money": 150.0, "name": "Jasmin", "password": "1573" }, { "money": 100.0, "name": "Ali", "password": "1856" } ], "admin": [ { "name": "Adam", "password": "6767" }, { "name": "Eva", "password": "2222" } ] } Im keep getting this error TypeError: 'float' object is not iterable
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.