Skip to content

Commit 8b084f9

Browse files
Program 17
1 parent 2d39927 commit 8b084f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lab Cycle 2/program17.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Program to accept a list of words and return the length of the longest word.
2+
3+
def longest_word(words):
4+
longest = 0
5+
for word in words:
6+
if len(word) > longest:
7+
longest = len(word)
8+
longest_word = word
9+
print("Longest word is",longest_word)
10+
print("Length of longest word is",longest)
11+
12+
print("Enter a list of words separated by spaces: ")
13+
words = input().split()
14+
longest_word(words)

0 commit comments

Comments
 (0)