Python Dictionaries

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 719123

    Comments posted to this topic are about the item Python Dictionaries

  • Stewart "Arturius" Campbell

    SSC Guru

    Points: 71767

    Nice one, thanks Steve
    Definitely time to dust off those old Python skills

    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • HappyGeek


    Points: 18678

    Hmm good question Steve, time to learn a bit of Python me thinks.


  • xsevensinzx

    One Orange Chip

    Points: 25558

    Easy one for me. Here is something cool to think about how list and dicts can work together.

    # Two dictionaries with two sets of rows and columns
    dictA = {'CustomerID': [1, 2, 3, 4, 5],  'FirstName': ['John', 'Joe', 'Sarah', 'Jane', 'Sam']}
    dictB = {'CustomerID': [1, 2, 3, 4, 5],  'FirstName': ['Sue', 'Aiden', 'Stephanie', 'Steve', 'Faye']}

    # List of my dictionaries
    myList = [dictA, dictB]

    # Being our dictionaries contain the same field names, we can use a list to help us keep track of each dict and iterate over them.
    # We can then use a forloop to iterate and list out each list within each dict.
    for records in myList:
         for customers in records['FirstName']:
              print customers

    Course, you could just combine the dicts too. But it's interesting to think about how they can be separate and reference each other too.

  • Ed Wagner

    SSC Guru

    Points: 286980

    I've never used python, so I guessed.  I guessed poorly.

  • TomThomson

    SSC Guru

    Points: 104773

    Ed Wagner - Friday, November 3, 2017 11:16 AM

    I've never used python, so I guessed.  I guessed poorly.

    I've never used it either,  but I have read odd bits of python code here and there (helping someone find his silly errors) and had a vague memory of hash tables being called dictionaries and using square brackets for keys.
    My son tells me I should learn the language, but I'm not convinced.


  • dstrickrott


    Points: 1951

    Nice question.  Thanks Steve.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply