Skip to content

Instantly share code, notes, and snippets.

@melvinlee
Created April 30, 2018 11:36
Show Gist options
  • Save melvinlee/a5f75fd6839bf658f9dd77f1b6bca5a9 to your computer and use it in GitHub Desktop.
Save melvinlee/a5f75fd6839bf658f9dd77f1b6bca5a9 to your computer and use it in GitHub Desktop.
Python find longest event word
def findLongestEventWord(sentense):
words = sentense.split()
event_words = [x for x in words if len(x) % 2 == 0]
return sorted(event_words, key=len, reverse=True)[0]
print(findLongestEventWord("The code is self explanatory") == 'code')
print(findLongestEventWord("Once created , you can click on Test and send a JSON as below") == 'Once')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment