how to get the largest word from a sentence in python code example
Example 1: python longest word in string
def find_longest_word(word_list):
longest_word = max(word_list, key=len)
return longest_word
Example 2: how to get the largest word from a sentence in python
# Longest word
# Reading sentence from user
sentence = input("Enter sentence: ")
# Finding longest word
longest = max(sentence.split(), key=len)
# Displaying longest word
print("Longest word is: ", longest)
print("And its length is: ", len(longest))