Python Practice › String Programs › Program 24
Smallest and largest word
Write a Python program to find the smallest and largest word in a string.
Input
"Learning is a part of life and we strive"
Output
a Learning
Approach
minandmaxwithkey=len.
Solution
words = "Learning is a part of life and we strive".split()print(min(words, key=len), max(words, key=len))Output
a Learning
Learn the concept
New to this topic? Read the lesson, then come back.