import sys
count = 0
emoticons = set(range(int('1f600', 16), int('1f650', 16)))
for row in sys.stdin:
    for char in row:
        if ord(char) in emoticons:
            count += 1
print('%d emoticons found' % count)
How to find and count emoticons in a string using python?