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

10th Apr 2021, 2:27 PM
Medo Elnahas
Medo Elnahas - avatar
3 ответов
+ 7
Correction txt = input() d=[] for word in txt.split(): d.append(len(word)) val = max(d) print(txt.split()[d.index(val)])
10th Apr 2021, 2:32 PM
Ayush Kumar
Ayush Kumar - avatar
+ 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
10th Apr 2021, 2:31 PM
Slick
Slick - avatar
+ 2
txt = input().split() d = [len(x) for x in txt] print(txt[d.index(max(d))]) # Hope this helps
10th Apr 2021, 4:14 PM
Calvin Thomas
Calvin Thomas - avatar