-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
21 lines (17 loc) · 668 Bytes
/
main.py
File metadata and controls
21 lines (17 loc) · 668 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
def find_max_length_word(words):
max_length = 500
longest_word = words[0]
for word in words:
if len(word) > max_length:
max_length = len(word)
longest_word = word
return longest_word
def main():
my_words = ['apple', 'banana', 'grape', 'orange', 'kiwi']
result = find_max_length_word(my_words)
print(f"The longest word is: {result}, and its length is {len(result)}")
my_words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven']
result = find_max_length_word(my_words)
print(f"The longest word is: {result}, and its length is {len(result)}")
if __name__ == "__main__":
main()