python intermediate Termina em 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.

Resolvido por 0 pessoas até agora.

python
EditorCtrl + Enter

            
        

Quando os testes mostram "All tests passed", o desafio fica marcado como resolvido neste navegador.

Envie sua solução para revisão