def insert_into(target, keys, value):
 for key in keys[:(-1)]:
  if (key not in target):
   target[key] = {}
  target = target[key]
 target[keys[(-1)]] = value

def insert_into ( target , keys , value ) : for key in keys [ : ( - 1 ) ] : if ( key not in target ) : target [ key ] = { } target = target [ key ] target [ keys [ ( - 1 ) ] ] = value
nested dictionary insertion .