Advertisement
aveBHS

Untitled

Mar 6th, 2021
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. file = open(input("Input file name>> "), 'r', encoding='utf-8')
  2. wordCount = 0
  3. for row in file.readlines():
  4.     row = row.rstrip()
  5.     if row.startswith('From'):
  6.         print(row.split()[1])
  7.         wordCount += 1
  8. print(f'There were {wordCount} lines in the file with From as the first word')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement