CBSE Class 11 Computer Science
Question 20 of 21
String Manipulation — Question 14
Back to all questions 14
Question Question 14
Write a program to input a line of text and print the biggest word (length wise) from it.
Solution
str = input("Enter a string: ")
words = str.split()
longWord = ''
for w in words :
if len(w) > len(longWord) :
longWord = w
print("Longest Word =", longWord)Output
Enter a string: TATA FOOTBALL ACADEMY WILL PLAY AGAINST MOHAN BAGAN
Longest Word = FOOTBALL
str
=
input
(
"Enter a string: "
)
words
=
str
.
split
()
longWord
=
''
for
w
in
words
:
if
len
(
w
)
>
len
(
longWord
) :
longWord
=
w
print
(
"Longest Word ="
,
longWord
)
Output
Enter a string: TATA FOOTBALL ACADEMY WILL PLAY AGAINST MOHAN BAGAN
Longest Word = FOOTBALL