Blog Archive

search

Tuesday, August 6, 2019

Write a Python function that takes a list of words and returns the length of the longest one

list1 = []
list2 = []
b = int(input('enter no of words'))
for i in range(b):
    c = input('enter word : ')
    list1.append(c)
    list2.append(len(c))
c = list2.index(max(list2))
print('longest word is ',list1[c],' length is ',list2[c])

No comments:

Post a Comment

Python program to create a string from two given strings concatenating uncommon characters of the said strings

PROGRAM :  a = input('Enter a string : ') b = input('Enter a string : ') c='' for i in a:     if(i not in b):...