Problem Description
Write a program to find the longest word in the list
Input:
1. The list size
2. The List Elements
Output:
The word with longest length
Refer sample input and output for formatting specification.
All float values are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.CODING ARENA
a=[]
n= int(input())
for x in range(0,n):
element=input()
a.append(element)
max1=len(a[0])
temp=a[0]
for i in a:
if(len(i)>max1):
max1=len(i)
temp=i
print("The word with the longest length is")
print(temp)
Test Case 1
Input (stdin)4 Australia Indianheritage States United
Expected OutputThe word with the longest length is Indianheritage
Test Case 2
Input (stdin)5 Australia Indian heritage States United Sanga tamil Literature
Expected OutputThe word with the longest length is Sanga tamil Literature
No comments:
Post a Comment