Friday 15 February 2013

python - how to print elements which occur only once in a list, without counting -


If I have a dictionary {key: [abccd]} and I want to print only unique values ​​corresponding to each key (In this case, (A, B, D)) apart from looping and counting it through each element, what is the most effective way to do this?

if the elements are sorted according to your example; You can use it:

  Add "" to itertools, which import groups from the print (group for [k, group (d ['key']) if lane (list (Group)) == 1]) # - & gt; A bd    

No comments:

Post a Comment