python intermediate 2026-11-17 終了

Flatten nested settings

Config files are often nested. Write flatten(d) that turns nested dicts into one level, joining keys with dots:

flatten({"db": {"host": "x", "port": 5432}, "debug": True})
# {"db.host": "x", "db.port": 5432, "debug": True}
  • Only dicts are flattened; lists and other values are kept as they are.
  • An empty nested dict disappears.

これまでに 0 人が解きました。

python
エディターCtrl + Enter

            
        

テストが "All tests passed" と表示すると、このブラウザーでチャレンジが解決済みになります。

解答をレビューに提出