forked from Dadsaster/python_class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.py
More file actions
20 lines (16 loc) · 586 Bytes
/
6.py
File metadata and controls
20 lines (16 loc) · 586 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Return the length of the longest word in the provided sentence.
# Your response should be a number.
def find_longest_word_in(string):
longest = 0
# turn string into list
list = string.split()
# loop through list
for word in list:
# check length of each against variable 'longest'
if len(word) > longest:
longest = len(word)
# if length of word is > 'longest' - make it the longest
# at end of looping return longest
return longest
print(find_longest_word_in("The quick brown fox jumped over the lazy dog"))
# should return 6