On 08/09/2012 04:06 PM, giuseppe.amatu...@gmail.com wrote:
> <SNIP>
>
> print unique
> {(4, 5): 1, (5, 4): 1, (4, 4): 2, (2, 3): 1, (4, 3): 2}
>
> I choose this solution because i could not install "from collections import 
> Counter". 

Nothing to install, at least for Python 2.7. collections is in the
standard library, and Counter is in collections (new in version 2.7)

> Anyway how i can print to a file the unique results without the brackets and 
> obtain something like this?
> 4 5 1
> 5 4 1
> 4 4 2
> 2 3 1
> 4 3 2
>
>

To print out a dict in an explicit format, you want a loop.

for key, val in unique.items():
     print key[0], key[1], val

Note that you cannot guarantee the order they will print out, once
stored in a dict.  You may want to sort them, or otherwise order them if
it matters.

<SNIP>

Note I added my responses after the parts of your message that I was
quoting.  To put the response first is called top-posting, and against
policy here.

-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to