re: Find longest word in a given string VIEW POST

VIEW FULL DISCUSSION
 

I know one of the tags is 'Javascript' but here is how I would do it in Python:

def get_longest_word(sentence):
    return max(sentence.split(' '), key=lambda x: len(x))

get_longest_word('Iam a verrrrry loooongggg sentence')
# result: loooongggg

code of conduct - report abuse