0
txt = input() d=[] for word in txt.split(): d.append(len(word)) max_len=max(d) for long in d: if long == max_len:
Can any one explain for me what wrong with this code This code for choose the longest word in your tzt
3 Answers
+ 7
Correction
txt = input()
d=[]
for word in txt.split():
d.append(len(word))
val = max(d)
print(txt.split()[d.index(val)])
+ 2
it cut off cause you put it in the title.
please paste it in the playground, save, and copy/paste a link to it here
+ 2
txt = input().split()
d = [len(x) for x in txt]
print(txt[d.index(max(d))])
# Hope this helps