Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # #!/usr/bin/python
- #
- # By dvdjaco
- # Exercise 8.5
- #
- f = raw_input('Enter a file name: ')
- try:
- fhand = open(f)
- count = 0
- for line in fhand:
- words = line.split()
- # print 'Debug:', words
- if len(words) == 0 or words[0] != 'From' : continue
- print words[1]
- count = count + 1
- print "There were", count, "lines with 'From' as first word"
- except IOError, err :
- print "Error opening file", f
- print "Error was:", err
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement