You can find the longest word in a string in Python by using the split()
method to split the string into a list of words, then looping through the list to compare the lengths of each word and keeping track of the longest one. Here's an example:
main.py332 chars14 lines
Now you can call this function with a string and it will return the longest word:
main.py89 chars3 lines
gistlibby LogSnag