Search Result

Collapse
4 results in 0.0042 seconds.
Keywords
Members
Tags
dictionaries
  •  

  • Reorder dictionary in pyrhon according to a list of values!!!

    Let us consider a dictionary:
    Code:
    sample_dict={1:'r099',2:'g444',3:'t555',4:'f444',5:'h666'}
    I want to re-order this dictionary in an order specified by a list containing the order of the dictionary keys that I desire. Let us say the desired order list is:
    Code:
    desired_order_list=[5,2,4,3,1]
    So, I want my dictionary to appear like this:
    Code:
    {5:'h666',2:'g444',4:'f444',3:'t555',1:'r099'}
    How do...
    See more | Go to post

  • Linking certain filenames in a directory and a dictonary?

    Hi. I'm trying to get my feet wet with programming and keep hitting some brick walls.

    I basically want to look in a folder for certain filenames. If the files are there, I would like the term linked to the filename to be in a listbox.

    I thought a dictionary would work:
    Code:
    dataset = { "File1.txt":"Picotiter Plate",
                        "File2.txt":"KeyPass Wells",
    ...
    See more | Go to post

  • Python:Query on Conditional Loops and the setdefault method

    >>>listoflist s = [['a', 'first'], ['b', 'second'], ['a', 'next'], ['c', 'third'], ['b', 'last']]
    >>> dd = {}
    >>>for item in listoflists:
    ... dd.setdefault(i tem[0], []).append(item)

    - The part which mentions 'item[0]' would be to have the first letter of each item in the list we created right ?
    - what does the ' [ ] ' signify in this case ? Does it mean to have a null value...
    See more | Go to post

  • sudipb
    started a topic A problem that I am facing on Python Dictionaries

    A problem that I am facing on Python Dictionaries

    I input the following:
    >>> collection={} #Initiate an empty dictionary
    >>>collection={ 'a':'first', 'a':'second','d ':'third','b':' fourth','e':'fi fth','b':'sixth '}
    >>> collection
    {'a':'second',' b':'sixth','e': 'fifth','d':'th ird'}

    Now my question is:

    Why does the output not include all the values (2 values for 'a' AND 2 values for 'b) BUT only shows the output of ONLY the...
    See more | Go to post
    Last edited by bvdet; Feb 20 '10, 01:45 PM. Reason: Removed email address
Working...