dict:
input = [{"name": "maysam", "age": 27, "localtion": "teh"}, {"name": "john", "age": 20, "localtion": "lon"}, {"name": "hamed", "age": 18, "localtion": "teh"}]
out = {"teh": {
"maysam": { "age": 27"},
"hamed": {"age": 18}}
, "lon": {
"john": {"age": 20}}
}
but really have got stuck at creating the nested dict. any body able to put me on path? i've been thinking on it for 2-3 hours and can't concentrate anymore...
from : input = [{"name": "maysam", "age": 27, "localtion": "teh"}, {"name": "john", "age": 20, "localtion": "lon"}, {"name": "hamed", "age": 18, "localtion": "teh"}] to: out = {"teh": { "maysam": {"age": 27}, "hamed": {"age": 18}, "john": {"age": 20}} } ?
Обсуждают сегодня