Longest word in a string Get link Facebook X Pinterest Email Other Apps Longest word in a stringQUESTION DESCRIPTIONLongest word is determined based on the number of characters in the word.Use lists to maintain the length of each word in the string and find the longest word.Input:The only input, first line is the string, sOutput:The longest word in s. l=[]a=input()l=a.split()ans=max(l,key=len)print(ans) Comments
Comments
Post a Comment