Find Longest Word
Returns the longest word in a string
- string
- length
- words
- longest-word
Code
def find_longest_word(s):
words = s.split()
return max(words, key=len) if words else ''Usage
System.out.println(findLongestWord("hello world123")); // "world123"