omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. multitech_news
    3. Posts

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by multitech_news

    • Setting values to each items in a list of a nested dictionary

      I'm trying to programmatically set a values to each item in a list inside a nested dictionary.

      for example, let's say my initial dictionary, which I constructed is:

      {'Abraham': {'subjects': ['Chem', 'Bio', 'Phy', 'Math']}}
      

      Given some lists of values:

      assess_type = ['Quiz', 'HW', 'ATTND', 'Exam']

      chem = ['127', '135', '17', '46']
      bio = ['154', '64', '14', '54']
      phy = ['115', '115', '15', '55']
      math = ['140', '160', '20', '40']
      And I want to achieve a result like this:

      {'Abraham': {'subjects': [
       'Chem': {'Quiz': '127', 'HW': '135', 'ATTND': '17', 'Exam': '46'},
       'Bio': {'Quiz': '154', 'HW': '64', 'ATTND': '14', 'Exam': '54'} ,
       'Phy': {'Quiz': '115', 'HW': '115', 'ATTND': '15', 'Exam': '55'},
       'Math': {'Quiz': '140', 'HW': '160', 'ATTND': '20', 'Exam': '40'}
        ]}}
      

      I can construct the dictionary itself, but where I am having issues is how to set the values programmatically. how do I index into the list inside the dictionary and set the value like that programmatically if I just have a list of values as written above?

      posted in Pythonista
      multitech_news
      multitech_news