How to access the values from a dictionary

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • argbsk
    New Member
    • Oct 2012
    • 2

    How to access the values from a dictionary

    Below is the dictionary

    Code:
    {0: ['Test logname : DISK$REGRES:[VERIFICATION.ACC]ACC_diff.log\n'], 
    1: ['FACILITY : ACC\n', 
    'FAILED LOGINACCOUNTINGTST\n', 'Total : 42\n', 'Passed : 41\n', 
    'Failed : 1\n', 
    'Not Run : 0\n', '\n', 
    'Test logname : DISK$REGRES:[VERIFICATION.BACKUP]BACKUP_diff.log\n'], 
    2: ['FACILITY : BACKUP\n', 'FAILED BACKUP_BEFORE\n', 
    '
    FAILED BACKUP_INTERCHANGE\n', 
    'Total : 34\n', 
    'Passed : 32\n', 
    'Failed : 2\n', 
    'Not Run : 0\n', '\n']}
    Last edited by zmbd; Oct 18 '12, 12:57 PM. Reason: When posting any code such as HTML, VBA, SQL please format it using the <CODE/> button. Also formated the code block for easier read. Raw cut and paste is hard on the eyes!
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    You might want to follow the entire tutorial located at this website (that's what I'm doing :) ). This url links to the dictionary http://www.tutorialspoint.com/python...dictionary.htm

    Comment

    • Glenton
      Recognized Expert Contributor
      • Nov 2008
      • 391

      #3
      Weird question. You would get far better help if you actually asked the question properly.

      Typically the dictionary is assigned to a variable, and the values can be accessed through the key. In the case the values are lists, which in turn can be accessed through an index.

      Suppose the dictionary you give above was assigned to the variable weirdDict.

      Then
      Code:
      >>weirdDict[2][0]
      >>FACILITY : BACKUP\n
      In general, better to tell us what you're trying to do.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Glenton,
        That is why I linked OP to the tutorial.

        Comment

        Working...