#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    44
    Rep Power
    2
    I just need help
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    default dictionaries would be useful, though not necessary. You can learn about them here.

    Given the amazing clue that you can convert an iterable to a tuple using tuple the keys of this dictionary are given by

    for i in drink_list:
    key = tuple(i)

    tuples are immutable. That means they cannot be changed. Therefor the hash function always returns the same value. That's why tuples, but not lists, can be used as dictionary keys.


    You might also use the generic pattern:

    container = EmptyContainer()
    loop:
    update(container,newInformation)
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    44
    Rep Power
    2
    ??
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    I can't think of how to say more without completely writing the function. There's not much to it.

    Can you start the python interpreter? Is python installed on your computer? Find the distribution at www.python.org .

    What does python respond if you type in "'hi'" ?

    Can you get python to import a module? Here's an experiment to prove yourself.
    Get python to show you the value of the hexdigits variable in the string module.

    Am I pissing you off with these pathetic questions? Good, you're ready to go. The program you're assigned is not much harder.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    PS. The doctest of your function, which you'd run on the command line with
    python -m doctest -v my_python_source.py
    reads
    >>> build_ranking_to_frequency([['cola', 'beer', 'coffee', 'tea'], ['cola', 'beer', 'tea', 'coffee'], ['cola', 'beer', 'coffee', 'tea']])
    {('cola', 'beer', 'coffee', 'tea'): 2, ('cola', 'beer', 'tea', 'coffee'): 1}

    If you study dictionaries long enough and practice with them in glorious variation you'll discover---you must discover---that the output of build_ranking_to_frequency is a dictionary.
    [code]Code tags[/code] are essential for python code and Makefiles!
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    44
    Rep Power
    2
    I am a comp major so yes i do have python visualizer and i know that i have to output a dictionary.

IMN logo majestic logo threadwatch logo seochat tools logo