Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions ch02-strings/e08b2_last_word_in_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ def last_word_alphabetically(filename):
"""
output = ''
for one_line in open(filename):
for one_word in one_line.split():
if not one_word.isalpha():
continue
if one_word > output:
output = one_word
split_line=one_line.split()
split_line.append(output)
output=max(split_line)
return output
8 changes: 3 additions & 5 deletions ch02-strings/e08b3_longest_word_in_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ def longest_word(filename):
"""
output = ''
for one_line in open(filename):
for one_word in one_line.split():
if not one_word.isalpha():
continue
if len(one_word) > len(output):
output = one_word
split_line=one_line.split()
split_line.append(output)
output=max(split_line)
return output