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