Created
April 30, 2018 11:36
-
-
Save melvinlee/a5f75fd6839bf658f9dd77f1b6bca5a9 to your computer and use it in GitHub Desktop.
Python find longest event word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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