0

How can I achieve the same thing in Python 2? I don't believe dotty_dict works in python 2.7 whereas it will in python 3.

from dotty_dict import dotty

dot = dotty()

alist = ['a.b.c.d.e.f.g.h.i', 'a.b.c.d.e.f.g.h.j', 'a.b.c.d.e.f.g.h.k']

for x in alist:

    dot[x] = 'test'

print(dot)

It needs to be python 2.7 due to the project I am working on.

Expected output is a dictionary:

{'a': {'b': {'c': {'d': {'e': {'f': {'g': {'h': {'i': 'test', 'j': 'test', 'k': 'test'}}}}}}}}}
deceze
  • 510,633
  • 85
  • 743
  • 889
tsai9_9
  • 3
  • 3
  • If you are looking for further help, please do not add comments to your question, but specifiy precisely which makes your own question different from the linked duplicate – Nico Haase Jan 24 '20 at 16:41
  • How about you actually try to understand and apply the solution in the duplicate before ranting your head off? https://repl.it/repls/NervousSentimentalJavadoc – deceze Jan 25 '20 at 06:17
  • I fail to see still how this is a duplicate. Similar solutions can be applied to different problems. I don't ask questions if I can figure it out on my own. – tsai9_9 Jan 26 '20 at 14:16
  • The fundamental problem being solved is the same. We're not here to present you bespoke code on a silver platter, we're here to help you solve the fundamental problem. – deceze Jan 26 '20 at 16:05

0 Answers0