Answers for "how to get the largest word from a sentence in python"

0

python longest word in string

def find_longest_word(word_list):  
    longest_word =  max(word_list, key=len)
    return longest_word
Posted by: Guest on November-02-2020
0

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))
Posted by: Guest on December-17-2020

Code answers related to "how to get the largest word from a sentence in python"

Python Answers by Framework

Browse Popular Code Answers by Language