Computer Science, asked by ar9858594, 1 day ago

find out of the largest and smallest word in the string word in the string"the surprising beefits of sarcasm",others?
1.)Take maxx as -9999 ,min as +9999

2.)convert the strings into list using split{}function

3.loop/iterate through the list and find the maximum length of word using len() fnction

.similar do with minimum


.hint```have two seperate varible named as min_val,ax_val to store minimum and maximum value

Answers

Answered by samarthkrv
0

Answer:

s = input("Enter a string:")

words = list(s.split(" "))

words.sort(key=len)

max_val = words[len(words)-1]

min_val = words[0]

print("The largest word is" , max_val)

print("The smallest word is" , min_val)

Explanation:

Similar questions