/
ch-1.py
39 lines (33 loc) · 1.12 KB
/
ch-1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
# -----------------------------------
# AUTHOR: Robert DiCicco
# DATE : 2023-07-10
# Challenge 225 Task 1 Max Words ( Python )
# -----------------------------------
lists = [["Perl and Raku belong to the same family.",
"I love Perl.",
"The Perl and Raku Conference."],
["The Weekly Challenge.",
"Python is the most popular guest language.",
"Team PWC has over 300 members."]]
max_num = 0
for lst in lists:
print("Input: @list = ",lst)
cnt = 0
sz = len(lst)
while cnt < sz:
words = lst[cnt].split()
num = len(words)
if num > max_num:
max_num = num
cnt += 1
print(f"Output: {max_num}\n")
max_num = 0
#-----------------------------------
# SAMPLE OUTPUT
# python .\MaxWords.py
# Input: @list = ['Perl and Raku belong to the same family.', 'I love Perl.', 'The Perl and Raku Conference.']
# Output: 8
# Input: @list = ['The Weekly Challenge.', 'Python is the most popular guest language.', 'Team PWC has over 300 members.']
# Output: 7
#-----------------------------------