Python: How to use an item from a python list which appears a specific number of times?
Question: Suppose I have a python list num = [1,2,5,3,4,4] and I know that there is an
item which appears 2 times in num. Now I want to use only that item. Is there
a predefined function to choose that item?

*There is no upper limit on value of items in num. 


Answer: There is no predefined function, no. You'll have to count all the items and
figure out which one can be found twice in the list.

You can use a [`collections.Counter()`
object](https://docs.python.org/2/library/collections.html#collections.Counter)
to get the counts, and from there it is reasonably easy to enumerate the
values that appear twice:

    
    
    from collections import Counter
    
    counts = Counter(num)
    twice = [n for n, count in counts.iteritems() if count == 2]
    

