Skip to content

Instantly share code, notes, and snippets.

@poliarush
Created September 28, 2016 12:42
Show Gist options
  • Save poliarush/2dbee405c14b6a5faca0cc67ff935910 to your computer and use it in GitHub Desktop.
Save poliarush/2dbee405c14b6a5faca0cc67ff935910 to your computer and use it in GitHub Desktop.
from collections import Counter
from collections import OrderedDict
msg = """If web server returns any error message
for any query by application server
then application server should catch and display
these error messages appropriately to the users"""
items = OrderedDict([(_, Counter(_)) for _ in msg.split()])
cleared = zip(*filter(lambda (k, v): len(v.values()) == sum(v.values()), items.iteritems()))[0]
print cleared
print cleared[0]
('If', 'web', 'any', 'for', 'query', 'by', 'then', 'should', 'and', 'display', 'to', 'the')
If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment