Apr-06-2020, 06:18 PM
Hi everyone,
I'm trying to transfer a list to a dictionnary and sort a new dict with key, but it's not success.
This is a list I need transfer:
[
{"numero":"20202020","name" : "Durand", "first":"Martin", "notes":[12,15.5,8,13]},
{"numero":"21212121","name" : "Dupond", "first":"Alain", "notes":[11,9.5,5.5,18]},
{"numero":"21202120","name" : "Bru", "first":"Mélissa", "notes":[11,19.5,15,8]},
{"numero":"20212021","name" :"Bosse", "first":"Mélissa", "notes":[13,19.5,15,8]},
{"numero":"21202120","name" : "Allard", "first":"Chloé", "notes":[11,9.5,2,8]},
{"numero":"20202020","name" : "Durand", "first":"Martin", "notes":[12,15.5,8,13]}
]
And this is a format of dict I need shows:
{"20202020":{"name" : "Durand", "first":"Martin", "notes":[12,15.5,8,13]},
"21212121":{"name" : "Dupond", "first":"Alain", "notes":[11,9.5,5.5,18]},
...
}
So, with this format: key is numero and value is another.
I REALLY NEED YOU HELP!!!! THANK YOU SO MUCH!!!
I'm trying to transfer a list to a dictionnary and sort a new dict with key, but it's not success.
This is a list I need transfer:
[
{"numero":"20202020","name" : "Durand", "first":"Martin", "notes":[12,15.5,8,13]},
{"numero":"21212121","name" : "Dupond", "first":"Alain", "notes":[11,9.5,5.5,18]},
{"numero":"21202120","name" : "Bru", "first":"Mélissa", "notes":[11,19.5,15,8]},
{"numero":"20212021","name" :"Bosse", "first":"Mélissa", "notes":[13,19.5,15,8]},
{"numero":"21202120","name" : "Allard", "first":"Chloé", "notes":[11,9.5,2,8]},
{"numero":"20202020","name" : "Durand", "first":"Martin", "notes":[12,15.5,8,13]}
]
And this is a format of dict I need shows:
{"20202020":{"name" : "Durand", "first":"Martin", "notes":[12,15.5,8,13]},
"21212121":{"name" : "Dupond", "first":"Alain", "notes":[11,9.5,5.5,18]},
...
}
So, with this format: key is numero and value is another.
I REALLY NEED YOU HELP!!!! THANK YOU SO MUCH!!!