- 1
Suggestions
This is problem: Given a text as input, find and output the longest word. Sample Input this is an awesome text Sample Output awesome This is my solution: txt = input() d = txt.split(" ") i = [] for c in d: v = len(c) i.append(v) o = max(i) f = i.index(o) print (d[f]) If there is any other solution shorter then it. Please tell me.
1 Resposta
+ 2
Hammad Karim
Yes, Just in two lines
list = txt.split(' ')
print (max(list, key = len))